Skip to content

Commit

Permalink
Fix build errors when initializing wasm_val_t values with macros (#3007)
Browse files Browse the repository at this point in the history
Errors were reported when initializing wasm_val_t values with WASM_I32_VAL like macros.
```
 error: missing initializer for member ‘wasm_val_t::__paddings’ [-Werror=missing-field-initializers]
   64 |     wasm_val_t res = {WASM_INIT_VAL};
```
And rename DEPRECATED to WASM_API_DEPRECATED to avoid using defines with generic names.
  • Loading branch information
Zzzabiyaka committed Jan 13, 2024
1 parent 0844245 commit 63012f0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions core/iwasm/include/wasm_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
#endif

#if defined(__GNUC__) || defined(__clang__)
#define DEPRECATED __attribute__((deprecated))
#define WASM_API_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#define DEPRECATED __declspec(deprecated)
#define WASM_API_DEPRECATED __declspec(deprecated)
#else
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
#define DEPRECATED
#define WASM_API_DEPRECATED
#endif

#ifdef __cplusplus
Expand Down Expand Up @@ -231,7 +231,7 @@ WASM_DECLARE_OWN(engine)
*/
WASM_API_EXTERN own wasm_engine_t* wasm_engine_new(void);
WASM_API_EXTERN own wasm_engine_t* wasm_engine_new_with_config(wasm_config_t*);
DEPRECATED WASM_API_EXTERN own wasm_engine_t *
WASM_API_DEPRECATED WASM_API_EXTERN own wasm_engine_t *
wasm_engine_new_with_args(mem_alloc_type_t type, const MemAllocOption *opts);

// Store
Expand Down Expand Up @@ -828,12 +828,12 @@ static inline void* wasm_val_ptr(const wasm_val_t* val) {
#endif
}

#define WASM_I32_VAL(i) {.kind = WASM_I32, .of = {.i32 = i}}
#define WASM_I64_VAL(i) {.kind = WASM_I64, .of = {.i64 = i}}
#define WASM_F32_VAL(z) {.kind = WASM_F32, .of = {.f32 = z}}
#define WASM_F64_VAL(z) {.kind = WASM_F64, .of = {.f64 = z}}
#define WASM_REF_VAL(r) {.kind = WASM_ANYREF, .of = {.ref = r}}
#define WASM_INIT_VAL {.kind = WASM_ANYREF, .of = {.ref = NULL}}
#define WASM_I32_VAL(i) {.kind = WASM_I32, .__paddings = {0}, .of = {.i32 = i}}
#define WASM_I64_VAL(i) {.kind = WASM_I64, .__paddings = {0}, .of = {.i64 = i}}
#define WASM_F32_VAL(z) {.kind = WASM_F32, .__paddings = {0}, .of = {.f32 = z}}
#define WASM_F64_VAL(z) {.kind = WASM_F64, .__paddings = {0}, .of = {.f64 = z}}
#define WASM_REF_VAL(r) {.kind = WASM_ANYREF, .__paddings = {0}, .of = {.ref = r}}
#define WASM_INIT_VAL {.kind = WASM_ANYREF, .__paddings = {0}, .of = {.ref = NULL}}

#define KILOBYTE(n) ((n) * 1024)

Expand Down

0 comments on commit 63012f0

Please sign in to comment.