diff --git a/ueforth/Makefile b/ueforth/Makefile index b1b6d0d..5088534 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -26,7 +26,7 @@ WINDOWS = $(OUT)/windows ESP32 = $(OUT)/esp32 DEPLOY = $(OUT)/deploy -CFLAGS_COMMON = -O2 -I ./ -I $(OUT) +CFLAGS_COMMON = -std=c++11 -O2 -I ./ -I $(OUT) CFLAGS_MINIMIZE = \ -s \ @@ -185,7 +185,7 @@ $(GEN)/esp32_boot.h: common/source_to_string.js $(ESP32_BOOT) | $(GEN) $< boot $(VERSION) $(REVISION) $(ESP32_BOOT) >$@ $(GEN)/dump_web_opcodes: web/dump_web_opcodes.c common/opcodes.h | $(GEN) - $(CC) $(CFLAGS) $< -o $@ + $(CXX) $(CFLAGS) $< -o $@ $(GEN)/web_cases.js: $(GEN)/dump_web_opcodes | $(GEN) $< cases >$@ @@ -253,7 +253,7 @@ $(POSIX)/ueforth: \ common/interp.h \ common/core.h \ $(GEN)/posix_boot.h | $(POSIX) - $(CC) $(CFLAGS) $< -o $@ $(LIBS) + $(CXX) $(CFLAGS) $< -o $@ $(LIBS) strip $(STRIP_ARGS) $@ # ---- WINDOWS ---- diff --git a/ueforth/common/calls.h b/ueforth/common/calls.h index f974b75..82fd682 100644 --- a/ueforth/common/calls.h +++ b/ueforth/common/calls.h @@ -15,7 +15,13 @@ #ifndef CALLTYPE # define CALLTYPE #endif + +#ifdef __cplusplus +typedef cell_t (CALLTYPE *call_t)(...); +#else typedef cell_t (CALLTYPE *call_t)(); +#endif + #define ct0 ((call_t) n0) #define CALLING_OPCODE_LIST \ diff --git a/ueforth/common/core.h b/ueforth/common/core.h index 0fb8ebb..2cd585d 100644 --- a/ueforth/common/core.h +++ b/ueforth/common/core.h @@ -56,7 +56,7 @@ static cell_t convert(const char *pos, cell_t n, cell_t base, cell_t *ret) { d -= 7; if (d < 10) { return 0; } } - if (d >= base) { return 0; } + if (d >= (uintptr_t) base) { return 0; } *ret = *ret * base + d; ++pos; } diff --git a/ueforth/common/source_to_string.js b/ueforth/common/source_to_string.js index fb80a93..990c51e 100755 --- a/ueforth/common/source_to_string.js +++ b/ueforth/common/source_to_string.js @@ -40,12 +40,7 @@ for (var i = 5; i < process.argv.length; i++) { source = source.replace('{{VERSION}}', version); source = source.replace('{{REVISION}}', revision); -source = source.replace(/\\/g, '\\\\'); -source = source.replace(/["]/g, '\\"'); -source = '"' + source.split('\n').join('\\n"\n"') + '\\n"'; -source = source.replace(/["] ["]/g, ''); -source = source.replace(/["] [(] ([^)]*)[)] ["]/g, '// $1'); -source = 'const char ' + name + '[] =\n' + source + ';\n'; +source = 'const char ' + name + '[] = R"""(\n' + source + ')""";\n'; process.stdout.write(source); diff --git a/ueforth/posix/posix_main.c b/ueforth/posix/posix_main.c index 1112356..e80d89c 100644 --- a/ueforth/posix/posix_main.c +++ b/ueforth/posix/posix_main.c @@ -24,7 +24,7 @@ #define STACK_CELLS (8 * 1024) #define PLATFORM_OPCODE_LIST \ - Y(DLSYM, tos = (cell_t) dlsym(a1, a0); --sp) \ + Y(DLSYM, tos = (cell_t) dlsym(a1, c0); --sp) \ FLOATING_POINT_LIST \ CALLING_OPCODE_LIST \