Skip to content

Commit

Permalink
Merge pull request #80 from alula/main
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent authored Oct 27, 2023
2 parents 2e9c86f + 5383d7f commit c663fe9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions w2c2/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -4656,6 +4656,8 @@ wasmCWriteModuleHeader(
fprintf(file, "#ifndef %s_H\n", moduleName);
fprintf(file, "#define %s_H\n\n", moduleName);

fputs("#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n", file);

wasmCWriteBaseInclude(file);
wasmCWriteModuleDeclarations(file, module, moduleName, pretty, debug, multipleModules);
fprintf(
Expand All @@ -4671,6 +4673,8 @@ wasmCWriteModuleHeader(
moduleName
);

fputs("#ifdef __cplusplus\n}\n#endif\n\n", file);

fprintf(file, "#endif /* %s_H */\n\n", moduleName);

if (fclose(file) != 0) {
Expand Down
10 changes: 10 additions & 0 deletions w2c2/w2c2_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@

#include <assert.h>

#ifdef __cplusplus
extern "C" {
#else

#ifndef __bool_true_false_are_defined
typedef enum bool {
false = 0,
true = 1
} bool;
#endif

#endif

typedef unsigned char U8;
typedef signed char I8;

Expand Down Expand Up @@ -903,4 +909,8 @@ wasmTableFree(

#define TF(table, index, t) ((t)((table).data[index]))

#ifdef __cplusplus
}
#endif

#endif /* W2C2_BASE_H */
8 changes: 8 additions & 0 deletions wasi/wasi.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ typedef long ssize_t;
#include <dirent.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef struct WasiFileDescriptor {
int fd;
DIR* dir;
Expand Down Expand Up @@ -637,4 +641,8 @@ wasiFromNativePath(
char *path
);

#ifdef __cplusplus
}
#endif

#endif /* W2C2_WASI_H */
8 changes: 8 additions & 0 deletions wasi/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <windows.h>
#include <errno.h>

#ifdef __cplusplus
extern "C" {
#endif

struct dirent {
long d_ino;
unsigned short d_reclen;
Expand Down Expand Up @@ -35,4 +39,8 @@ struct DIR {
HANDLE handle;
};

#ifdef __cplusplus
}
#endif

#endif /* W2C2_WASI_WIN32_H */

0 comments on commit c663fe9

Please sign in to comment.