Skip to content

Commit

Permalink
simplified macro for enabling/disabling warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Jul 20, 2023
1 parent 0d45f2e commit 4aac723
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/asset_library_update_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

#include "version.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/classes/json.hpp>
#include <godot_cpp/classes/project_settings.hpp>
#include <godot_cpp/classes/scene_tree.hpp>
#include <godot_cpp/classes/scene_tree_timer.hpp>
#include <godot_cpp/classes/window.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

void AssetLibraryUpdateChecker::_bind_methods() {
#define REG_CLASS_NAME AssetLibraryUpdateChecker
Expand Down
4 changes: 2 additions & 2 deletions src/asset_library_update_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

#include "utils.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/http_request.hpp>
#include <godot_cpp/classes/ref_counted.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

using namespace godot;

Expand Down
4 changes: 2 additions & 2 deletions src/colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include "utils_compiler.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/variant/color.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

class Colors {
public:
Expand Down
4 changes: 2 additions & 2 deletions src/data_graphs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#include "circular_buffer.h"
#include "colors.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/canvas_item.hpp>
#include <godot_cpp/classes/font.hpp>
#include <godot_cpp/classes/ref_counted.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

#include <map>

Expand Down
4 changes: 2 additions & 2 deletions src/debug_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "grouped_text.h"
#include "utils.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/config_file.hpp>
#include <godot_cpp/classes/dir_access.hpp>
#include <godot_cpp/classes/file_access.hpp>
Expand All @@ -21,7 +21,7 @@ MSVC_WARNING_DISABLE(4244)
#include <godot_cpp/classes/scene_tree.hpp>
#include <godot_cpp/classes/standard_material3d.hpp>
#include <godot_cpp/classes/window.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

#include <limits.h>

Expand Down
4 changes: 2 additions & 2 deletions src/debug_draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
#include "colors.h"
#include "geometry_generators.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/camera3d.hpp> // TODO: need to be removed with vararg functions in release build.
#include <godot_cpp/classes/canvas_item.hpp>
#include <godot_cpp/classes/canvas_layer.hpp>
#include <godot_cpp/classes/font.hpp>
#include <godot_cpp/classes/ref_counted.hpp>
#include <godot_cpp/classes/sub_viewport.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

#include <memory>

Expand Down
4 changes: 2 additions & 2 deletions src/debug_draw_config_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include "colors.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/font.hpp>
#include <godot_cpp/classes/ref_counted.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

using namespace godot;

Expand Down
4 changes: 2 additions & 2 deletions src/debug_draw_config_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include "colors.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/ref_counted.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

using namespace godot;

Expand Down
4 changes: 2 additions & 2 deletions src/debug_geometry_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include "draw_stats.h"
#include "utils.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/main_loop.hpp>
#include <godot_cpp/classes/scene_tree.hpp>
#include <godot_cpp/classes/sub_viewport.hpp>
#include <godot_cpp/classes/world3d.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

#include <array>

Expand Down
4 changes: 2 additions & 2 deletions src/debug_geometry_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "math_utils.h"
#include "render_instances.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/array_mesh.hpp>
#include <godot_cpp/classes/camera3d.hpp>
#include <godot_cpp/classes/canvas_item.hpp>
Expand All @@ -19,7 +19,7 @@ MSVC_WARNING_DISABLE(4244)
#include <godot_cpp/classes/rendering_server.hpp>
#include <godot_cpp/classes/standard_material3d.hpp>
#include <godot_cpp/classes/texture.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

#include <map>

Expand Down
4 changes: 2 additions & 2 deletions src/draw_cache.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/font.hpp>
#include <godot_cpp/classes/ref.hpp>
#include <godot_cpp/godot.hpp>
#include <godot_cpp/variant/builtin_types.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

using namespace godot;

Expand Down
4 changes: 2 additions & 2 deletions src/draw_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include "utils_compiler.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/ref_counted.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

using namespace godot;

Expand Down
4 changes: 2 additions & 2 deletions src/geometry_generators.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include "utils_compiler.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/godot.hpp>
#include <godot_cpp/variant/builtin_types.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

#include <array>
#include <vector>
Expand Down
4 changes: 2 additions & 2 deletions src/grouped_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

#include "utils_compiler.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/canvas_item.hpp>
#include <godot_cpp/classes/font.hpp>
#include <godot_cpp/variant/builtin_types.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

#include <functional>
#include <memory>
Expand Down
4 changes: 2 additions & 2 deletions src/math_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include "utils_compiler.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/godot.hpp>
#include <godot_cpp/variant/builtin_types.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

#include <vector>

Expand Down
4 changes: 2 additions & 2 deletions src/render_instances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

#include "draw_stats.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/mesh.hpp>
#include <godot_cpp/classes/multi_mesh.hpp>
#include <godot_cpp/classes/texture.hpp>
#include <godot_cpp/classes/time.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

template <class T, size_t _TStepSize>
struct TempBigBuffer {
Expand Down
4 changes: 2 additions & 2 deletions src/render_instances.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "math_utils.h"
#include "utils.h"

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/array_mesh.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

#include <array>

Expand Down
4 changes: 2 additions & 2 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <unordered_set>
#include <vector>

MSVC_WARNING_DISABLE(4244)
GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/classes/node.hpp>
#include <godot_cpp/core/binder_common.hpp>
Expand All @@ -23,7 +23,7 @@ MSVC_WARNING_DISABLE(4244)
#include <godot_cpp/godot.hpp>
#include <godot_cpp/variant/builtin_types.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
MSVC_WARNING_RESTORE(4244)
GODOT_WARNING_RESTORE()

#if REAL_T_IS_DOUBLE
typedef godot::PackedFloat64Array PackedRealArray;
Expand Down
10 changes: 8 additions & 2 deletions src/utils_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@
#define EXPAND_MACRO(x)
#endif

//
#if _MSC_VER

#define GODOT_WARNING_DISABLE() \
__pragma(warning(disable : 4244 26451 26495))
#define GODOT_WARNING_RESTORE() \
__pragma(warning(default : 4244 26451 26495))

#define MSVC_WARNING_DISABLE(n) __pragma(warning(disable \
: n))
#define MSVC_WARNING_RESTORE(n) __pragma(warning(default \
: n))

#else
#define GODOT_WARNING_DISABLE(n)
#define GODOT_WARNING_RESTORE(n)
#define MSVC_WARNING_DISABLE(n)
#define MSVC_WARNING_RESTORE(n)
#endif
#endif

0 comments on commit 4aac723

Please sign in to comment.