Skip to content

Commit

Permalink
move MSVC warning config
Browse files Browse the repository at this point in the history
moved from `Pragma.h` to `CMakeLists.txt`

also updated justifications since some of them were out of date, incorrect, or unnecessarily editorial
  • Loading branch information
ab9rf committed Sep 16, 2024
1 parent 1c36881 commit ee8ada4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
21 changes: 18 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,26 @@ if(MSVC)
# see https://msdn.microsoft.com/en-us/library/074af4b6.aspx
add_compile_options("/wd4503")

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

# suppress C4251 - VC++ will warn when exporting an entire class which contains members
# referencing unexported compound types is unsafe. because we don't guarantee a stable API
# for our exports, we don't really care about this, so we choose to be lazy and continue to
# export entire classes instead of exporting on a method-by-method basis
add_compile_options("/wd4251")

# suppress C4068 - VC++ will warn for unknown pragmas by default. this is equivalent to gcc
# -Wno-unknown-pragmas. we could work around this with sufficiently complex macros
add_compile_options("/wd4068")

# suppress C4244 - VC++ warns by default (with /Wall) about narrowing conversions that may lose data
# (such as double -> int or int32_t -> int16_t). dfhack has many of these, mostly related to Lua
# this is equivalent to gcc -Wno_conversions which is the default as gcc -Wall doesn't enable -Wconversions
add_compile_options("/wd4244")

# MSVC panics if an object file contains more than 65,279 sections. this
# happens quite frequently with code that uses templates, such as vectors.
add_compile_options("/bigobj")
Expand Down
8 changes: 0 additions & 8 deletions library/include/Pragma.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ distribution.
#define DFHACK_TRANQUILITY

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

#endif

0 comments on commit ee8ada4

Please sign in to comment.