Core: Conditional compound to fix Msvc, better assert but printf based, Fix tests
This commit is contained in:
@@ -243,7 +243,7 @@ gen_value(Token *pos, Value a) {
|
||||
default: {
|
||||
if (is_string(type)) {
|
||||
int length = 0;
|
||||
gen("{(uint8_t *)\"");
|
||||
gen("CORE_ConditionalCompound(String){(uint8_t *)\"");
|
||||
for (int i = 0; i < a.intern_val.len; i++) {
|
||||
if (a.intern_val.str[i] == '\n') {
|
||||
length += 2;
|
||||
@@ -845,8 +845,14 @@ compile_to_c_code() {
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
int printf(const char *format, ...);
|
||||
#ifndef Assert
|
||||
#define Assert(x) do{if(!(x))(*(volatile int *)0 = 0);}while(0)
|
||||
#define Assert(x) do{ \
|
||||
if(!(x)) { \
|
||||
printf("Assertion failed! %%s(%%d): %%s\n", __FILE__, __LINE__, #x); \
|
||||
*(volatile int *)0 = 0; \
|
||||
} \
|
||||
}while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AssertMessage
|
||||
@@ -866,7 +872,15 @@ compile_to_c_code() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#define BufferSize(x) (sizeof(x)/sizeof((x)[0]))
|
||||
#define BufferSize(x) ((int)(sizeof(x)/sizeof((x)[0])))
|
||||
|
||||
#ifdef __clang__
|
||||
#define CORE_ConditionalCompound(x) (x)
|
||||
#elif _MSC_VER
|
||||
#define CORE_ConditionalCompound(x)
|
||||
#else
|
||||
#define CORE_ConditionalCompound(x) (x)
|
||||
#endif
|
||||
|
||||
)");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user