Skip to content

Commit ee8ada4

Browse files
committed
move MSVC warning config
moved from `Pragma.h` to `CMakeLists.txt` also updated justifications since some of them were out of date, incorrect, or unnecessarily editorial
1 parent 1c36881 commit ee8ada4

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

CMakeLists.txt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,26 @@ if(MSVC)
8888
# see https://msdn.microsoft.com/en-us/library/074af4b6.aspx
8989
add_compile_options("/wd4503")
9090

91-
# suppress C4267 - VC++ complains whenever we implicitly convert an integer to
92-
# a smaller type, and most of the time this is just conversion from 64 to 32 bits
93-
# for things like vector sizes, which are never that big anyway.
91+
# suppress C4267 - VC++ considers a narrowing conversion from size_t to a smaller
92+
# integer type a warning. this is technically correct but there are so many instances
93+
# of this that we don't want to fix, so....
9494
add_compile_options("/wd4267")
9595

96+
# suppress C4251 - VC++ will warn when exporting an entire class which contains members
97+
# referencing unexported compound types is unsafe. because we don't guarantee a stable API
98+
# for our exports, we don't really care about this, so we choose to be lazy and continue to
99+
# export entire classes instead of exporting on a method-by-method basis
100+
add_compile_options("/wd4251")
101+
102+
# suppress C4068 - VC++ will warn for unknown pragmas by default. this is equivalent to gcc
103+
# -Wno-unknown-pragmas. we could work around this with sufficiently complex macros
104+
add_compile_options("/wd4068")
105+
106+
# suppress C4244 - VC++ warns by default (with /Wall) about narrowing conversions that may lose data
107+
# (such as double -> int or int32_t -> int16_t). dfhack has many of these, mostly related to Lua
108+
# this is equivalent to gcc -Wno_conversions which is the default as gcc -Wall doesn't enable -Wconversions
109+
add_compile_options("/wd4244")
110+
96111
# MSVC panics if an object file contains more than 65,279 sections. this
97112
# happens quite frequently with code that uses templates, such as vectors.
98113
add_compile_options("/bigobj")

library/include/Pragma.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ distribution.
2828
#define DFHACK_TRANQUILITY
2929

3030
#ifdef _MSC_VER
31-
// don't generate warnings because we're lazy about how we do exports
32-
#pragma warning( disable: 4251 )
33-
// do not issue warning for unknown pragmas (equivalent to gcc -Wno-unknown-pragmas)
34-
#pragma warning( disable: 4068 )
35-
// disable warnings regarding narrowing conversions (equivalent to gcc -Wno-conversion)
36-
#pragma warning( disable: 4244)
37-
// disable warnings regarding narrowing conversions of size_t
38-
#pragma warning( disable: 4267)
3931
#endif
4032

4133
#endif

0 commit comments

Comments
 (0)