diff --git a/project/components/interface.parsing.cpp b/project/components/interface.parsing.cpp index fd23ee0..619c5df 100644 --- a/project/components/interface.parsing.cpp +++ b/project/components/interface.parsing.cpp @@ -4413,13 +4413,6 @@ CodeTypedef parse_typedef() if ( tok.Type == TokType::BraceCurly_Close ) { - typedef struct - { - int a; - int b; - }* Something; - - // Its an inplace definition // typdef { ... } ; ok_to_parse = true; diff --git a/project/components/types.hpp b/project/components/types.hpp index f6fc2a1..871a0cc 100644 --- a/project/components/types.hpp +++ b/project/components/types.hpp @@ -3,9 +3,9 @@ using LogFailType = sw(*)(char const*, ...); // By default this library will either crash or exit if an error is detected while generating codes. // Even if set to not use fatal, fatal will still be used for memory failures as the library is unusable when they occur. #ifdef GEN_DONT_USE_FATAL - constexpr LogFailType log_failure = log_fmt; + #define log_failure log_fmt #else - constexpr LogFailType log_failure = fatal; + #define log_failure fatal #endif enum class AccessSpec : u32 diff --git a/project/dependencies/debug.hpp b/project/dependencies/debug.hpp index c439040..1103f2b 100644 --- a/project/dependencies/debug.hpp +++ b/project/dependencies/debug.hpp @@ -33,5 +33,27 @@ void assert_handler( char const* condition, char const* file, s32 line, char con s32 assert_crash( char const* condition ); void process_exit( u32 code ); +#if Build_Debug + #define fatal( fmt, ... ) \ + do \ + { \ + local_persist thread_local \ + char buf[GEN_PRINTF_MAXLEN] = { 0 }; \ + \ + str_fmt(buf, GEN_PRINTF_MAXLEN, fmt, __VA_ARGS__); \ + GEN_PANIC(buf); \ + } \ + while (0) +#else + +# define fatal( fmt, ... ) \ + do \ + { \ + str_fmt_out_err_va( fmt, __VA_ARGS__ ); \ + process_exit(1); \ + } \ + while (0) +#endif + #pragma endregion Debug diff --git a/project/dependencies/printing.cpp b/project/dependencies/printing.cpp index 18223fc..7591eaf 100644 --- a/project/dependencies/printing.cpp +++ b/project/dependencies/printing.cpp @@ -541,6 +541,16 @@ sw str_fmt_file( struct FileInfo* f, char const* fmt, ... ) return res; } +sw str_fmt( char* str, sw n, char const* fmt, ... ) +{ + sw res; + va_list va; + va_start( va, fmt ); + res = str_fmt_va( str, n, fmt, va ); + va_end( va ); + return res; +} + sw str_fmt_out_va( char const* fmt, va_list va ) { return str_fmt_file_va( file_get_standard( EFileStandard_OUTPUT ), fmt, va ); diff --git a/project/dependencies/printing.hpp b/project/dependencies/printing.hpp index 0608beb..23a3808 100644 --- a/project/dependencies/printing.hpp +++ b/project/dependencies/printing.hpp @@ -9,6 +9,7 @@ struct FileInfo; // NOTE: A locally persisting buffer is used internally char* str_fmt_buf ( char const* fmt, ... ); char* str_fmt_buf_va ( char const* fmt, va_list va ); +sw str_fmt ( char* str, sw n, char const* fmt, ... ); sw str_fmt_va ( char* str, sw n, char const* fmt, va_list va ); sw str_fmt_out_va ( char const* fmt, va_list va ); sw str_fmt_out_err ( char const* fmt, ... ); @@ -32,30 +33,5 @@ sw log_fmt(char const* fmt, ...) return res; } -inline -sw fatal(char const* fmt, ...) -{ - local_persist thread_local - char buf[GEN_PRINTF_MAXLEN] = { 0 }; - - va_list va; - -#if Build_Debug - va_start(va, fmt); - str_fmt_va(buf, GEN_PRINTF_MAXLEN, fmt, va); - va_end(va); - - assert_crash(buf); - return -1; -#else - va_start(va, fmt); - str_fmt_out_err_va( fmt, va); - va_end(va); - - exit(1); - return -1; -#endif -} - #pragma endregion Printing