nlib
Config_win32.h
1
2
#pragma once
3
#ifndef INCLUDE_NN_NLIB_CONFIG_WIN32_H_
4
#define INCLUDE_NN_NLIB_CONFIG_WIN32_H_
5
#ifndef INCLUDE_NN_NLIB_CONFIG_H_
6
# error do not include directly
7
#endif
8
9
#if defined(_MSC_VER)
10
11
#include <Windows.h>
12
#include <crtdbg.h>
13
#if _WIN32_WINNT < 0x601
14
# pragma message("Windows SDK is old. Please install Windows SDK 7.1 or higher.")
15
#endif
16
17
#define NLIB_PATHMAPPER_FORSAMPLE \
18
nlib_ns::NativePathMapper g_PathMapper; \
19
inline void InitPathMapperForSample() { \
20
char dir[1024]; \
21
::GetModuleFileNameA(NULL, &dir[0], 1024); \
22
*const_cast<char*>(nlib_strrchr(dir, '\\')) = '\0'; \
23
*const_cast<char*>(nlib_strrchr(dir, '\\')) = '\0'; \
24
g_PathMapper.AddMap(dir, "nlibpath:
25
g_PathMapper.AddMap(dir, "nlibpath:
26
}
27
28
#define NLIB_MAINFUNC int main(int argc, char** argv) { \
29
bool result = SampleMain(argc, argv); nlib_printf(result ? "OK\n" : "NG\n"); \
30
return result ? 0 : 1; }
31
#define NLIB_EXCEPTION_ENABLED
32
33
#if 0
34
// Klocwork likes it better than crtdbg.h
35
#include <cassert>
// NOLINT
36
#define NLIB_ASSERT assert
37
#else
38
#define NLIB_ASSERT _ASSERT
39
#endif
40
41
#ifdef _DEBUG
42
#define NLIB_ASSERT_NOERR(e) \
43
(void) (((e) == 0) || \
44
(1 != _CrtDbgReport(_CRT_ASSERT, __FILE__, __LINE__, NULL, \
45
"%s", nlib_error_string(e))) || \
46
(_CrtDbgBreak(), 0))
47
#else
48
#define NLIB_ASSERT_NOERR(e) ((void)0)
49
#endif
50
51
#define NLIB_ALIGNAS(x) __declspec(align(x))
52
#define NLIB_ALIGNOF(tp) __alignof(tp)
53
#endif
54
55
#define NLIB_HAS_NATIVE_TYPETRAITS
56
57
//
58
// for C++11
59
//
60
#define NLIB_CXX11_SWAPHEADER
61
#define NLIB_CXX11_STATIC_ASSERTIONS
62
#define NLIB_CXX11_NULL_POINTER_CONSTANT
63
#define NLIB_CXX11_RVALUE_REFERENCES
64
#define NLIB_CXX11_LAMBDAS
65
#define NLIB_CXX11_UNIQUEPTR
66
#define NLIB_CXX11_EXPLICIT_VIRTUAL_OVERRIDES
67
#define NLIB_CXX11_RANGE_BASED_FOR
68
#define NLIB_CXX11_STDLIB_CHRONO
69
#define NLIB_CXX11_STDLIB_ATOMIC
70
#define NLIB_CXX11_STDLIB_ARRAY
71
#define NLIB_CXX11_STDLIB_UNORDERED
72
#define NLIB_CXX11_STDLIB_TUPLE
73
#ifdef __STDC_NO_THREADS__
74
# error
75
#endif
76
77
#if _MSC_VER >= 1800
78
# define NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS
79
# define NLIB_CXX11_TEMPLATE_ALIAS
80
# define NLIB_CXX11_VARIADIC_TEMPLATES
81
# define NLIB_CXX11_DELEGATING_CONSTRUCTORS
82
# define NLIB_CXX11_STDLIB_RANDOM
83
# define NLIB_CXX11_DEFAULT_TEMPLATE_ARGUMENT_FOR_FUNCTION_TEMPLATES
84
#endif
85
#if _MSC_VER >= 1900
86
# define NLIB_CXX11_CONSTEXPR
87
# define NLIB_CXX11_NOEXCEPT
88
# define NLIB_CXX11_NEW_CHARACTER_TYPES
89
# define NLIB_CXX11_ALIGNMENT_SUPPORT
90
# define NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS
91
#endif
92
93
#ifdef _DEBUG
94
NLIB_NAMESPACE_BEGIN
95
96
class
NlibMemChecker {
97
public
:
98
NlibMemChecker() {
99
_CrtMemCheckpoint(&s1_);
100
}
101
void
Start() {
102
_CrtMemCheckpoint(&s1_);
103
}
104
bool
Check() {
105
_CrtMemState s2, s3;
106
_CrtMemCheckpoint(&s2);
107
return
!_CrtMemDifference( &s3, &s1_, &s2);
108
}
109
110
private
:
111
_CrtMemState s1_;
112
};
113
114
#define NLIB_MEMCHECKER ::nlib_ns::NlibMemChecker nlib_memchecker_
115
#define NLIB_MEMCHECKER_START nlib_memchecker_.Start()
116
#define NLIB_MEMCHECKER_CHECK nlib_memchecker_.Check()
117
118
NLIB_NAMESPACE_END
119
#endif
120
121
#define NLIB_NOEMPTYFILE_2(L) namespace { char NoEmptyFileDummy ## L; } // NOLINT
122
#define NLIB_NOEMPTYFILE_1(L) NLIB_NOEMPTYFILE_2(L)
123
#define NLIB_NOEMPTYFILE() NLIB_NOEMPTYFILE_1(__LINE__)
124
125
#define NLIB_HAS_VIRTUALMEMORY
126
127
#define NLIB_THREAD_EXIT_CPP_THROW_NLIB_EXCEPTION
128
#ifdef NLIB_EXCEPTION_ENABLED
129
#undef nlib_thread_cleanup_push
130
#undef nlib_thread_cleanup_pop
131
#define nlib_thread_cleanup_push(fn, arg) switch (0) case 0: default: { \
132
__pragma(warning(push)) \
133
__pragma(warning(disable:4456)) \
134
struct nlib_thread_cleanup_handler_ _thread_cleanup_handler = { fn, arg, NULL }; \
135
__pragma(warning(pop)) \
136
nlib_thread_cleanup_push_(&_thread_cleanup_handler); try {
137
#define nlib_thread_cleanup_pop(exec) } catch(...) { nlib_thread_cleanup_pop_(1); throw; } \
138
nlib_thread_cleanup_pop_(exec); }
139
#endif
140
141
#endif // INCLUDE_NN_NLIB_CONFIG_WIN32_H_
© 2012-2016 Nintendo Co., Ltd. All rights reserved.