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