Skip to content

Commit

Permalink
Merge pull request #4942 from ab9rf/pragma-cleaning
Browse files Browse the repository at this point in the history
clean up msvc warning suppression
  • Loading branch information
myk002 authored Sep 17, 2024
2 parents e7b9309 + bd74e01 commit d26c5dd
Show file tree
Hide file tree
Showing 19 changed files with 22 additions and 90 deletions.
24 changes: 20 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,27 @@ 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 as this is potentially unsafe. because we don't
# guarantee a stable ABI for exports, we don't really care about this, and 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 (which is enabled for gcc below).
# we could work around this with sufficiently complex macros
add_compile_options("/wd4068")

# suppress C4244 - VC++ warns by default (with /W3) 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 Expand Up @@ -224,7 +240,7 @@ if(UNIX)
# default to hidden symbols
# ensure compatibility with older CPUs
add_definitions(-DLINUX_BUILD)
set(GCC_COMMON_FLAGS "-fvisibility=hidden -mtune=generic -Wall -Werror -Wl,--disable-new-dtags")
set(GCC_COMMON_FLAGS "-fvisibility=hidden -mtune=generic -Wall -Werror -Wl,--disable-new-dtags -Wno-unknown-pragmas")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COMMON_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COMMON_FLAGS}")
if(DFHACK_BUILD_64)
Expand Down
2 changes: 0 additions & 2 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@ set(MAIN_HEADERS
include/Memory.h
include/MiscUtils.h
include/Module.h
include/Pragma.h
include/MemAccess.h
include/ModuleFactory.h
include/PluginManager.h
include/PluginStatics.h
include/Pragma.h
include/RemoteClient.h
include/RemoteServer.h
include/RemoteTools.h
Expand Down
1 change: 0 additions & 1 deletion library/include/BitArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ distribution.
*/

#pragma once
#include "Pragma.h"
#include "Export.h"
#include "Error.h"
#include <stdint.h>
Expand Down
1 change: 0 additions & 1 deletion library/include/ColorText.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ distribution.
*/

#pragma once
#include "Pragma.h"
#include "Export.h"

#include <list>
Expand Down
1 change: 0 additions & 1 deletion library/include/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ distribution.
*/

#pragma once
#include "Pragma.h"
#include "Export.h"
#include "ColorText.h"
#include <atomic>
Expand Down
2 changes: 0 additions & 2 deletions library/include/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ distribution.

#pragma once

#include "Pragma.h"

#include "Console.h"
#include "Export.h"
#include "Hooks.h"
Expand Down
1 change: 0 additions & 1 deletion library/include/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ distribution.

#include "Export.h"
#include "MiscUtils.h"
#include "Pragma.h"

namespace DFHack
{
Expand Down
3 changes: 0 additions & 3 deletions library/include/Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,5 @@ distribution.
#define _FILE_OFFSET_BITS 64
#endif

// one file for telling the MSVC compiler where it can shove its pointless warnings
#include "Pragma.h"

// C99 integer types
#include <stdint.h>
1 change: 0 additions & 1 deletion library/include/MemAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ distribution.
#ifndef PROCESS_H_INCLUDED
#define PROCESS_H_INCLUDED

#include "Pragma.h"
#include "Export.h"
#include <iostream>
#include <cstring>
Expand Down
65 changes: 0 additions & 65 deletions library/include/Pragma.h

This file was deleted.

1 change: 0 additions & 1 deletion library/include/RemoteClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ distribution.
*/

#pragma once
#include "Pragma.h"
#include "Export.h"
#include "ColorText.h"
#include "Core.h"
Expand Down
1 change: 0 additions & 1 deletion library/include/RemoteServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ distribution.
*/

#pragma once
#include "Pragma.h"
#include "Export.h"
#include "RemoteClient.h"
#include "Core.h"
Expand Down
1 change: 0 additions & 1 deletion library/include/RemoteTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ distribution.
*/

#pragma once
#include "Pragma.h"
#include "Export.h"
#include "RemoteServer.h"

Expand Down
1 change: 0 additions & 1 deletion library/include/TileTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ distribution.

#pragma once

#include "Pragma.h"
#include "Export.h"
#include "DataDefs.h"

Expand Down
1 change: 0 additions & 1 deletion library/include/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ distribution.

#include <algorithm>

#include "Pragma.h"
#include "Export.h"

#include "DataDefs.h"
Expand Down
1 change: 0 additions & 1 deletion library/include/VersionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ distribution.
#include <vector>

#include "Export.h"
#include "Pragma.h"

namespace DFHack
{
Expand Down
1 change: 0 additions & 1 deletion library/include/VersionInfoFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ distribution.

#include <memory>

#include "Pragma.h"
#include "Export.h"

class TiXmlElement;
Expand Down
2 changes: 1 addition & 1 deletion plugins/plant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ command_result df_createplant(color_ostream &out, const df::coord &pos, const pl

auto des = Maps::getTileDesignation(pos);
CHECK_NULL_POINTER(des);
if (des->bits.flow_size > (des->bits.liquid_type == tile_liquid::Magma ? 0 : 3))
if (des->bits.flow_size > (des->bits.liquid_type == tile_liquid::Magma ? 0U : 3U))
{
out.printerr("Can't create plant: Too much liquid!\n");
return CR_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion plugins/regrass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static bool valid_tile(color_ostream &out, regrass_options options, df::map_bloc
TRACE(log, out).print("Invalid tile: Tree\n");
return false; // Not ground tile.
}
else if (des.bits.flow_size > (des.bits.liquid_type == tile_liquid::Magma ? 0 : 3))
else if (des.bits.flow_size > (des.bits.liquid_type == tile_liquid::Magma ? 0U : 3U))
{ // Under water/magma (df::plant_raw::shrub_drown_level is usually 4).
TRACE(log, out).print("Invalid tile: Liquid\n");
return false;
Expand Down

0 comments on commit d26c5dd

Please sign in to comment.