make the console toggleable at runtime instead of compilation time
This commit is contained in:
parent
5f5571e241
commit
9272355696
4
Makefile
4
Makefile
|
@ -63,6 +63,10 @@ else
|
||||||
OPTIMIZE_FLAG = -O3 -ffast-math
|
OPTIMIZE_FLAG = -O3 -ffast-math
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq ($(findstring Win32,$(OS)),)
|
||||||
|
LDFLAGS += -mwindows
|
||||||
|
endif
|
||||||
|
|
||||||
CFLAGS += -Wall $(OPTIMIZE_FLAG) $(INCLUDE_DIRS) $(DEBUG_FLAG) -I.
|
CFLAGS += -Wall $(OPTIMIZE_FLAG) $(INCLUDE_DIRS) $(DEBUG_FLAG) -I.
|
||||||
|
|
||||||
APPEND_CFLAGS := $(CFLAGS)
|
APPEND_CFLAGS := $(CFLAGS)
|
||||||
|
|
15
verbosity.c
15
verbosity.c
|
@ -26,6 +26,10 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
@ -50,11 +54,22 @@ static bool main_verbosity = false;
|
||||||
void verbosity_enable(void)
|
void verbosity_enable(void)
|
||||||
{
|
{
|
||||||
main_verbosity = true;
|
main_verbosity = true;
|
||||||
|
#ifdef _WIN32
|
||||||
|
AllocConsole();
|
||||||
|
AttachConsole( GetCurrentProcessId()) ;
|
||||||
|
freopen( "CON", "w", stdout );
|
||||||
|
freopen( "CON", "w", stderr );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void verbosity_disable(void)
|
void verbosity_disable(void)
|
||||||
{
|
{
|
||||||
main_verbosity = false;
|
main_verbosity = false;
|
||||||
|
#ifdef _WIN32
|
||||||
|
HWND wnd = GetConsoleWindow();
|
||||||
|
FreeConsole();
|
||||||
|
PostMessage(wnd, WM_CLOSE, 0, 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool verbosity_is_enabled(void)
|
bool verbosity_is_enabled(void)
|
||||||
|
|
Loading…
Reference in New Issue