From 9f19d64062022e9c34a303abb7f6d219747150eb Mon Sep 17 00:00:00 2001 From: skejeton Date: Thu, 14 Mar 2024 10:46:21 -0300 Subject: [PATCH] Option to compile Windows build in console subsystem --- CMakeLists.txt | 10 +++++----- src/misc.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b93f0e12..50c83a86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(tophat) if(MSVC) set(umka_dir ${CMAKE_CURRENT_SOURCE_DIR}/lib/umka/umka_windows_msvc) set(umka_lib_path ${umka_dir}/libumka_static.lib) - + execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cmd/win-buildmodules.bat WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULT_VARIABLE ret) if (NOT ret EQUAL "0") message(FATAL_ERROR "Failed to generate staembed.c") @@ -15,11 +15,11 @@ if(MSVC) "src/*.c" ) - add_executable(tophat WIN32 ${th_sources}) - + add_executable(tophat ${th_sources}) + # NOTE(skejeton): _USE_MATH_DEFINES flag for M_PI and so on. - # NOTE(skejeton): UMKA_STATIC flag for we are linking umka statically not as a DLL. - target_compile_definitions(tophat PUBLIC UMKA_STATIC _USE_MATH_DEFINES) + # NOTE(skejeton): UMKA_STATIC flag for we are linking umka statically not as a DLL. + target_compile_definitions(tophat PUBLIC UMKA_STATIC _USE_MATH_DEFINES _CONSOLE) # target_compile_options(tophat PRIVATE /fsanitize=address) target_include_directories(tophat PUBLIC diff --git a/src/misc.c b/src/misc.c index c0672fe1..162aa689 100644 --- a/src/misc.c +++ b/src/misc.c @@ -46,7 +46,7 @@ th_error(char *text, ...) va_list args; va_start(args, text); -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_CONSOLE) #include char buf[4096]; vsnprintf(buf, 4096, text, args); @@ -62,7 +62,7 @@ th_info(char *text, ...) { va_list args; va_start(args, text); -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_CONSOLE) #include char buf[4096]; vsnprintf(buf, 4096, text, args);