wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

Compiler complains about the const pointer being written to.

Open fire opened this issue 1 year ago • 2 comments
trafficstars

https://github.com/bytecodealliance/wasm-micro-runtime/blob/7affac0ed35d7feec1cbe20f443248027b764435/core/iwasm/common/wasm_c_api.c#L2360

wasm_module_t *
wasm_module_new(wasm_store_t *store, const wasm_byte_vec_t *binary)
{
    LoadArgs args = { 0 };
    args.name = "";
    args.clone_wasm_binary = true;
    return wasm_module_new_ex(store, (wasm_byte_vec_t *)binary, &args);
}

Can we construct the name, true and ??? values for LoadArgs to avoid this error?

Like LoadArgs args = { };

fire avatar Jul 13 '24 21:07 fire

Here's an example of the compiler warning.

wasm-micro-runtime/core/iwasm/common/wasm_runtime_common.c:1399:15: error: assigning to 'char *' from 'const char[1]' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    args.name = "";
              ^ ~~

fire avatar Jul 13 '24 21:07 fire

Hi, can you try the following conversion? Like

args.name = (char *)"";

TianlongLiang avatar Jul 15 '24 10:07 TianlongLiang