Do not rely on a define for disabling warnings

Using a define to determine whether to disable warnings introduces a
dependency on the header inclusion order and thus can prevent the
warnings from being enabled.

Fixes #1173

Change-Id: I21f5bca78a83bfe4642e9b01abd220b9fbba31a4
This commit is contained in:
Sergiu Deitsch
2025-09-28 17:16:47 +02:00
parent d4e3ba3173
commit 77d7044d23
2 changed files with 4 additions and 14 deletions
+3 -7
View File
@@ -1,5 +1,5 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2023 Google Inc. All rights reserved.
// Copyright 2025 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
@@ -28,10 +28,8 @@
//
// This file has the sole purpose to silence warnings when including Ceres.
// This is not your usual header guard. The macro CERES_WARNINGS_DISABLED
// shows up again in reenable_warnings.h.
#ifndef CERES_WARNINGS_DISABLED
#define CERES_WARNINGS_DISABLED
// NOTE: An include guard is not necessary and in fact counterproductive because
// #pragma warning(push) will depend on the inclusion order.
#ifdef _MSC_VER
#pragma warning(push)
@@ -40,5 +38,3 @@
// "if you are deriving from a type in the Standard C++ Library"
#pragma warning(disable : 4251)
#endif
#endif // CERES_WARNINGS_DISABLED
+1 -7
View File
@@ -1,5 +1,5 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2023 Google Inc. All rights reserved.
// Copyright 2025 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
@@ -27,12 +27,6 @@
// POSSIBILITY OF SUCH DAMAGE.
//
// This is not your usual header guard. See disable_warnings.h
#ifdef CERES_WARNINGS_DISABLED
#undef CERES_WARNINGS_DISABLED
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif // CERES_WARNINGS_DISABLED