diff options
author | quou <quou@disroot.org> | 2024-12-27 18:52:48 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-12-27 18:52:48 +1100 |
commit | d920e5d62020d751ccaa3491cc66275ade749011 (patch) | |
tree | e806a95c598e255f9883de98cc350a3b9279d0ce /qstd | |
parent | e8c93463b2ae5114f0c88e768e5625abac9d5a50 (diff) |
building and running on windows with visual studio
Diffstat (limited to 'qstd')
-rw-r--r-- | qstd/plat.c | 70 | ||||
-rw-r--r-- | qstd/str.c | 4 |
2 files changed, 72 insertions, 2 deletions
diff --git a/qstd/plat.c b/qstd/plat.c index 61385ff..7f07b96 100644 --- a/qstd/plat.c +++ b/qstd/plat.c @@ -84,3 +84,73 @@ void pbreak(int code) { } #endif + +#ifdef plat_win + +#define _POSIX_SOURCE +#define _GNU_SOURCE + +#include <stdarg.h> +#include <stdio.h> + +#include <windows.h> +#include <stdio.h> +#include <io.h> + +int imp_assert( + int val, + const char* expr, + const char* file, + int line +) { + if (!val) { + print_err( + "%d:%s: Assertion failed: %s.\n", + line, + file, + expr + ); + pbreak(420); + return 0; + } + return 1; +} + +void print(const char* fmt, ...) { + char buf[1024]; + va_list args; + va_start(args, fmt); + vsprintf(buf, fmt, args); + va_end(args); + OutputDebugStringA(buf); +} + +void print_err(const char* fmt, ...) { + char buf[1024]; + va_list args; + va_start(args, fmt); + vsprintf(buf, fmt, args); + va_end(args); + OutputDebugStringA(buf); +} + +void print_war(const char* fmt, ...) { + char buf[1024]; + va_list args; + va_start(args, fmt); + vsprintf(buf, fmt, args); + va_end(args); + OutputDebugStringA(buf); +} + +void pbreak(int code) { +#if defined(DEBUG) && defined(plat_x86) + __debugbreak(); + (void)code; +#else + exit(code); +#endif +} + + +#endif
\ No newline at end of file @@ -39,9 +39,9 @@ int string_equal(const char* a, const char* b) { int string_copy(char* dst, const char* src) { int i; - for (i = 0; *src; src++, dst++, i++) { + for (i = 0; *src; src++, dst++, i++) *dst = *src; - } + *dst = 0; return i; } |