Fix lib.h falling back to TARGET_LINUX during wasm_module and c module compilation

This commit is contained in:
2026-07-26 13:31:13 +02:00
parent 822b59d70e
commit 9baf6605ed
18 changed files with 62 additions and 36 deletions
+11 -6
View File
@@ -10,17 +10,23 @@
#define IMPORT(fnct) __attribute__((import_module("env"), import_name(fnct)))
#if !defined(TARGET_FAIL) && !defined(TARGET_LINUX_BAREMETAL) && \
!defined(TARGET_LINUX)
!defined(TARGET_LINUX) && !defined(TARGET_WASM)
// Set to linux while editing to prevent lsp errors
#define TARGET_LINUX
#endif
// Both the wasm wrapper and the wasm module use lib.h
// TARGET_WASM is for the wasm module...
#ifdef TARGET_WASM
#define PRINT(fmt, ...) print(fmt)
#endif
// ...the rest is for the wasm wrapper
#ifdef TARGET_FAIL
#define MAIN void os_main(void)
#define PRINT(fmt, ...)
#define PRINT_ERROR(fmt, ...)
#define PRINT_SUCCESS(fmt, ...)
#define HOST_PRINT(msg)
#define RET(val) return
#endif
@@ -29,11 +35,11 @@
#define PRINT(fmt, ...)
#define PRINT_ERROR(fmt, ...)
#define PRINT_SUCCESS(fmt, ...)
#define HOST_PRINT(msg)
#define RET(val) return
#define RET(val) return val
#endif
#ifdef TARGET_LINUX
#include "stdio.h"
#define MAIN int main(int argc, char *argv[])
#define PRINT(fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__)
#define PRINT_ERROR(fmt, ...) \
@@ -42,8 +48,7 @@
#define PRINT_SUCCESS(fmt, ...) \
fprintf(stdout, "[Success] "); \
fprintf(stdout, fmt, ##__VA_ARGS__)
#define HOST_PRINT(msg) print(msg)
#define RET(val) return val;
#define RET(val) return val
#endif
typedef uint16_t enc_t;