From 49851a2972f0c8cee500974df99e3f1e4ef351eb Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 17 Sep 2018 12:14:34 +0200 Subject: [PATCH] Implement the rest of #14; close #14 --- flips.cpp | 9 ++++++--- global.h | 2 +- make.bat | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/flips.cpp b/flips.cpp index 41f2390..3617682 100644 --- a/flips.cpp +++ b/flips.cpp @@ -6,10 +6,12 @@ #include "flips.h" #include "crc32.h" -//get rid of dependencies on libstdc++, they eat 200KB on Windows +#ifdef __MINGW32__ +//get rid of dependencies on libstdc++, they waste 200KB on this platform void* operator new(size_t n) { return malloc(n); } // forget allocation failures, let them segfault. void operator delete(void * p) { free(p); } -extern "C" void __cxa_pure_virtual() { while(1); } +extern "C" void __cxa_pure_virtual() { abort(); } +#endif //TODO: delete @@ -449,7 +451,8 @@ config::~config() { LPWSTR data = this->flatten(); //puts(data); - filewrite::write(this->filename, (struct mem){ (uint8_t*)data, wcslen(data)*sizeof(WCHAR) }); + struct mem m = { (uint8_t*)data, wcslen(data)*sizeof(WCHAR) }; + filewrite::write(this->filename, m); free(data); free(this->filename); } diff --git a/global.h b/global.h index 1c609c2..2780432 100644 --- a/global.h +++ b/global.h @@ -48,7 +48,7 @@ public: virtual size_t len() = 0; virtual const uint8_t * ptr() = 0; - struct mem get() { return (struct mem){ (uint8_t*)ptr(), len() }; } + struct mem get() { struct mem m = { (uint8_t*)ptr(), len() }; return m; } virtual ~filemap() {} }; diff --git a/make.bat b/make.bat index 708c28a..f6e8fa0 100644 --- a/make.bat +++ b/make.bat @@ -1,5 +1,6 @@ ::This script creates a heavily optimized binary. For debugging, you're better off using 'mingw32-make'. +::Feel free to point this elsewhere. call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat" ::call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat" ::call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat" @@ -25,13 +26,12 @@ if exist flips.exe goto h ::/TP - force C++ because void foo(int bar = 0); is syntax error in C ::/MT - use static msvcrt ::/GL - LTCG -::/openmp - enable OpenMP -::cl /c /Oy /Oi /Os /Ox /EHs-c- /Gz /D_CRT_SECURE_NO_WARNINGS /WX /wd4700 /nologo /TP /MT /GL *.cpp *.c -rem /openmp +::/openmp - enable OpenMP (adds an extra DLL, so let's not) cl /c /Oy /Oi /Os /Ox /EHs-c- /Gz /D_CRT_SECURE_NO_WARNINGS /WX /wd4700 /nologo /TP /MT /GL /Imsvc ^ /DUSE_DIVSUFSORT /Ilibdivsufsort-2.0.1\include /DHAVE_CONFIG_H libdivsufsort-2.0.1\lib\*.c ^ *.c *.cpp -rc /nologo flips.rc +::rc doesn't have a /nologo, just let it spam +rc flips.rc link /LTCG /nologo *.obj /subsystem:windows flips.res user32.lib gdi32.lib comctl32.lib shell32.lib comdlg32.lib advapi32.lib /out:flips.exe