Skip to content

Commit d26c5dd

Browse files
authored
Merge pull request #4942 from ab9rf/pragma-cleaning
clean up msvc warning suppression
2 parents e7b9309 + bd74e01 commit d26c5dd

19 files changed

Lines changed: 22 additions & 90 deletions

CMakeLists.txt

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,27 @@ 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 as this is potentially unsafe. because we don't
98+
# guarantee a stable ABI for exports, we don't really care about this, and so we choose to
99+
# be lazy and continue to 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 (which is enabled for gcc below).
104+
# we could work around this with sufficiently complex macros
105+
add_compile_options("/wd4068")
106+
107+
# suppress C4244 - VC++ warns by default (with /W3) about narrowing conversions that may lose data
108+
# (such as double -> int or int32_t -> int16_t). dfhack has many of these, mostly related to Lua
109+
# this is equivalent to gcc -Wno_conversions which is the default as gcc -Wall doesn't enable -Wconversions
110+
add_compile_options("/wd4244")
111+
96112
# MSVC panics if an object file contains more than 65,279 sections. this
97113
# happens quite frequently with code that uses templates, such as vectors.
98114
add_compile_options("/bigobj")
@@ -224,7 +240,7 @@ if(UNIX)
224240
# default to hidden symbols
225241
# ensure compatibility with older CPUs
226242
add_definitions(-DLINUX_BUILD)
227-
set(GCC_COMMON_FLAGS "-fvisibility=hidden -mtune=generic -Wall -Werror -Wl,--disable-new-dtags")
243+
set(GCC_COMMON_FLAGS "-fvisibility=hidden -mtune=generic -Wall -Werror -Wl,--disable-new-dtags -Wno-unknown-pragmas")
228244
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COMMON_FLAGS}")
229245
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COMMON_FLAGS}")
230246
if(DFHACK_BUILD_64)

library/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,10 @@ set(MAIN_HEADERS
6969
include/Memory.h
7070
include/MiscUtils.h
7171
include/Module.h
72-
include/Pragma.h
7372
include/MemAccess.h
7473
include/ModuleFactory.h
7574
include/PluginManager.h
7675
include/PluginStatics.h
77-
include/Pragma.h
7876
include/RemoteClient.h
7977
include/RemoteServer.h
8078
include/RemoteTools.h

library/include/BitArray.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ distribution.
2323
*/
2424

2525
#pragma once
26-
#include "Pragma.h"
2726
#include "Export.h"
2827
#include "Error.h"
2928
#include <stdint.h>

library/include/ColorText.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ distribution.
2323
*/
2424

2525
#pragma once
26-
#include "Pragma.h"
2726
#include "Export.h"
2827

2928
#include <list>

library/include/Console.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ distribution.
2323
*/
2424

2525
#pragma once
26-
#include "Pragma.h"
2726
#include "Export.h"
2827
#include "ColorText.h"
2928
#include <atomic>

library/include/Core.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ distribution.
2424

2525
#pragma once
2626

27-
#include "Pragma.h"
28-
2927
#include "Console.h"
3028
#include "Export.h"
3129
#include "Hooks.h"

library/include/Error.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ distribution.
3030

3131
#include "Export.h"
3232
#include "MiscUtils.h"
33-
#include "Pragma.h"
3433

3534
namespace DFHack
3635
{

library/include/Internal.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,5 @@ distribution.
3434
#define _FILE_OFFSET_BITS 64
3535
#endif
3636

37-
// one file for telling the MSVC compiler where it can shove its pointless warnings
38-
#include "Pragma.h"
39-
4037
// C99 integer types
4138
#include <stdint.h>

library/include/MemAccess.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ distribution.
2828
#ifndef PROCESS_H_INCLUDED
2929
#define PROCESS_H_INCLUDED
3030

31-
#include "Pragma.h"
3231
#include "Export.h"
3332
#include <iostream>
3433
#include <cstring>

library/include/Pragma.h

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)