16 #ifndef INCLUDE_NN_NLIB_CONFIG_WIN32_H_ 17 #define INCLUDE_NN_NLIB_CONFIG_WIN32_H_ 18 #ifndef INCLUDE_NN_NLIB_CONFIG_H_ 19 #error do not include directly 26 #if _WIN32_WINNT < 0x601 27 #pragma message("Windows SDK is old. Please install Windows SDK 7.1 or higher.") 30 #define NLIB_PATHMAPPER_FORSAMPLE \ 31 nlib_ns::NativePathMapper g_pathmapper; \ 32 nlib_ns::NativePathMapper& g_PathMapper = g_pathmapper; \ 33 inline void InitPathMapperForSample() { \ 35 ::GetModuleFileNameA(nullptr, &dir[0], 1024); \ 36 *const_cast<char*>(nlib_strrchr(dir, '\\')) = '\0'; \ 37 g_pathmapper.AddMap(dir, "nlibpath: 38 g_pathmapper.AddMap(dir, "nlibpath: 39 SetCurrentDirectoryA(dir); \ 42 #define NLIB_MAINFUNC \ 43 int main(int argc, char** argv) { \ 44 bool result = SampleMain(argc, argv); \ 45 nlib_printf(result ? "OK\n" : "NG\n"); \ 46 return result ? 0 : 1; \ 48 #ifndef __cpp_exceptions 49 #define __cpp_exceptions 199711L 55 #define NLIB_ASSERT assert 57 #define NLIB_ASSERT _ASSERT 61 #define NLIB_ASSERT_NOERR(e) \ 62 (void)(((e) == 0) || \ 63 (1 != _CrtDbgReport(_CRT_ASSERT, __FILE__, __LINE__, nullptr, "%s", \ 64 nlib_error_string(e))) || \ 67 #define NLIB_ASSERT_NOERR(e) ((void)0) 70 #define NLIB_ALIGNAS(x) __declspec(align(x)) 71 #define NLIB_ALIGNOF(tp) __alignof(tp) 77 class NlibMemChecker {
79 __declspec(noinline) NlibMemChecker() { _CrtMemCheckpoint(&s1_); }
80 __declspec(noinline)
void Start() { _CrtMemCheckpoint(&s1_); }
81 __declspec(noinline)
bool Check() {
83 _CrtMemCheckpoint(&s2);
84 return !_CrtMemDifference(&s3, &s1_, &s2);
91 #define NLIB_MEMCHECKER ::nlib_ns::NlibMemChecker nlib_memchecker_ 92 #define NLIB_MEMCHECKER_START nlib_memchecker_.Start() 93 #define NLIB_MEMCHECKER_CHECK nlib_memchecker_.Check() 98 #define NLIB_NOEMPTYFILE_2(L) \ 100 char NoEmptyFileDummy##L; \ 102 #define NLIB_NOEMPTYFILE_1(L) NLIB_NOEMPTYFILE_2(L) 103 #define NLIB_NOEMPTYFILE() NLIB_NOEMPTYFILE_1(__LINE__) 105 #define NLIB_HAS_VIRTUALMEMORY 107 #ifdef __cpp_exceptions 108 #define NLIB_THREAD_EXIT_CPP_THROW_NLIB_EXCEPTION 109 #undef nlib_thread_cleanup_push 110 #undef nlib_thread_cleanup_pop 111 #define nlib_thread_cleanup_push(fn, arg) \ 115 __pragma(warning(push)) __pragma(warning( \ 116 disable : 4456)) struct nlib_thread_cleanup_handler_ _thread_cleanup_handler = { \ 118 __pragma(warning(pop)) nlib_thread_cleanup_push_(&_thread_cleanup_handler); \ 120 #define nlib_thread_cleanup_pop(exec) \ 123 nlib_thread_cleanup_pop_(1); \ 126 nlib_thread_cleanup_pop_(exec); \ 130 #endif // INCLUDE_NN_NLIB_CONFIG_WIN32_H_