Skip to content

Add missing stddef.h include to lib_export.h#4952

Merged
lum1n0us merged 1 commit into
bytecodealliance:mainfrom
siemens:dev/fix_lib_export_includes
May 27, 2026
Merged

Add missing stddef.h include to lib_export.h#4952
lum1n0us merged 1 commit into
bytecodealliance:mainfrom
siemens:dev/fix_lib_export_includes

Conversation

@stertl
Copy link
Copy Markdown
Contributor

@stertl stertl commented May 22, 2026

The core/iwasm/include/lib_export.h misses an include of <stddef.h>, which is required for the definition of NULL.

Testing

// lib_export_test.c
#include <stdint.h>
#include "lib_export.h"

struct WASMExecEnv;
typedef struct WASMExecEnv *wasm_exec_env_t;

int foo_wrapper(wasm_exec_env_t exec_env) {
  (void)exec_env;
  return 42; }

static NativeSymbol native_symbols[] = {EXPORT_WASM_API_WITH_SIG2(foo, "()i")};

uint32_t get_native_lib(char **p_module_name, NativeSymbol **p_native_symbols)
{
  *p_module_name = "env";
  *p_native_symbols = native_symbols;
  return sizeof(native_symbols) / sizeof(NativeSymbol);
}
$ clang -shared -I ./core/iwasm/include -o lib_export_test.so lib_export_test.c
lib_export_test.c:6:41: error: use of undeclared identifier 'NULL'
static NativeSymbol native_symbols[] = {EXPORT_WASM_API_WITH_SIG2(foo, "()i")};
                                        ^
./core/iwasm/include/lib_export.h:39:53: note: expanded from macro 'EXPORT_WASM_API_WITH_SIG2'
    { #symbol, (void *)symbol##_wrapper, signature, NULL }
                                                    ^
lib_export_test.c:12:16: error: invalid application of 'sizeof' to an incomplete type 'NativeSymbol[]' (aka 'struct NativeSymbol[]')
  return sizeof(native_symbols) / sizeof(NativeSymbol);
               ^~~~~~~~~~~~~~~~
2 errors generated.

- needed for definition of NULL
@stertl stertl force-pushed the dev/fix_lib_export_includes branch from 44c083a to da63441 Compare May 26, 2026 07:17
@lum1n0us lum1n0us merged commit 2b25b20 into bytecodealliance:main May 27, 2026
503 of 509 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants