From c0b883816f2dcebb51e34755547f97dc02a5d6c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Piltz?= Date: Mon, 19 May 2014 08:21:00 +0200 Subject: [PATCH] Disabled warning C4251 Added the files disable_warnings.h and reenable_warnings.h which need to be included by every file that uses the macro CERES_EXPORT. Change-Id: I176326a600d094a4524bac873564fcbf8efd2456 --- include/ceres/c_api.h | 3 ++ include/ceres/conditioned_cost_function.h | 2 + include/ceres/cost_function.h | 3 ++ include/ceres/covariance.h | 3 ++ include/ceres/crs_matrix.h | 3 ++ include/ceres/internal/disable_warnings.h | 44 ++++++++++++++++++++++ include/ceres/internal/reenable_warnings.h | 38 +++++++++++++++++++ include/ceres/iteration_callback.h | 3 ++ include/ceres/local_parameterization.h | 3 ++ include/ceres/loss_function.h | 5 ++- include/ceres/normal_prior.h | 3 ++ include/ceres/problem.h | 5 ++- include/ceres/solver.h | 3 ++ include/ceres/types.h | 3 ++ 14 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 include/ceres/internal/disable_warnings.h create mode 100644 include/ceres/internal/reenable_warnings.h diff --git a/include/ceres/c_api.h b/include/ceres/c_api.h index 632542e9b..71f41fd22 100644 --- a/include/ceres/c_api.h +++ b/include/ceres/c_api.h @@ -39,6 +39,7 @@ #define CERES_PUBLIC_C_API_H_ #include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" #ifdef __cplusplus extern "C" { @@ -140,4 +141,6 @@ CERES_EXPORT void ceres_solve(ceres_problem_t* problem); } #endif +#include "ceres/internal/reenable_warnings.h" + #endif /* CERES_PUBLIC_C_API_H_ */ diff --git a/include/ceres/conditioned_cost_function.h b/include/ceres/conditioned_cost_function.h index 2a12ba6fe..3f0087c78 100644 --- a/include/ceres/conditioned_cost_function.h +++ b/include/ceres/conditioned_cost_function.h @@ -39,6 +39,7 @@ #include "ceres/cost_function.h" #include "ceres/internal/scoped_ptr.h" #include "ceres/types.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -93,5 +94,6 @@ class CERES_EXPORT ConditionedCostFunction : public CostFunction { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" #endif // CERES_PUBLIC_CONDITIONED_COST_FUNCTION_H_ diff --git a/include/ceres/cost_function.h b/include/ceres/cost_function.h index fee3e73c1..45292ecdd 100644 --- a/include/ceres/cost_function.h +++ b/include/ceres/cost_function.h @@ -48,6 +48,7 @@ #include "ceres/internal/macros.h" #include "ceres/internal/port.h" #include "ceres/types.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -142,4 +143,6 @@ class CERES_EXPORT CostFunction { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_COST_FUNCTION_H_ diff --git a/include/ceres/covariance.h b/include/ceres/covariance.h index b6e9a6ae3..245381a2d 100644 --- a/include/ceres/covariance.h +++ b/include/ceres/covariance.h @@ -36,6 +36,7 @@ #include "ceres/internal/port.h" #include "ceres/internal/scoped_ptr.h" #include "ceres/types.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -419,4 +420,6 @@ class CERES_EXPORT Covariance { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_COVARIANCE_H_ diff --git a/include/ceres/crs_matrix.h b/include/ceres/crs_matrix.h index 687c9586d..d2d628941 100644 --- a/include/ceres/crs_matrix.h +++ b/include/ceres/crs_matrix.h @@ -33,6 +33,7 @@ #include #include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -80,4 +81,6 @@ struct CERES_EXPORT CRSMatrix { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_CRS_MATRIX_H_ diff --git a/include/ceres/internal/disable_warnings.h b/include/ceres/internal/disable_warnings.h new file mode 100644 index 000000000..78924de13 --- /dev/null +++ b/include/ceres/internal/disable_warnings.h @@ -0,0 +1,44 @@ +// Ceres Solver - A fast non-linear least squares minimizer +// Copyright 2014 Google Inc. All rights reserved. +// http://code.google.com/p/ceres-solver/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither the name of Google Inc. nor the names of its contributors may be +// used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// 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 + +#ifdef _MSC_VER +#pragma warning( push ) +// Disable the warning C4251 which is trigerred by stl classes in +// Ceres' public interface. To quote MSDN: "C4251 can be ignored " +// "if you are deriving from a type in the Standard C++ Library" +#pragma warning( disable : 4251 ) +#endif + +#endif // CERES_WARNINGS_DISABLED diff --git a/include/ceres/internal/reenable_warnings.h b/include/ceres/internal/reenable_warnings.h new file mode 100644 index 000000000..1f477d8d2 --- /dev/null +++ b/include/ceres/internal/reenable_warnings.h @@ -0,0 +1,38 @@ +// Ceres Solver - A fast non-linear least squares minimizer +// Copyright 2014 Google Inc. All rights reserved. +// http://code.google.com/p/ceres-solver/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither the name of Google Inc. nor the names of its contributors may be +// used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// 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 diff --git a/include/ceres/iteration_callback.h b/include/ceres/iteration_callback.h index 5eca392da..237ada6e0 100644 --- a/include/ceres/iteration_callback.h +++ b/include/ceres/iteration_callback.h @@ -36,6 +36,7 @@ #define CERES_PUBLIC_ITERATION_CALLBACK_H_ #include "ceres/types.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -219,4 +220,6 @@ class CERES_EXPORT IterationCallback { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_ITERATION_CALLBACK_H_ diff --git a/include/ceres/local_parameterization.h b/include/ceres/local_parameterization.h index ecac5ba3c..3ab21fc30 100644 --- a/include/ceres/local_parameterization.h +++ b/include/ceres/local_parameterization.h @@ -34,6 +34,7 @@ #include #include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -188,4 +189,6 @@ class CERES_EXPORT QuaternionParameterization : public LocalParameterization { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_LOCAL_PARAMETERIZATION_H_ diff --git a/include/ceres/loss_function.h b/include/ceres/loss_function.h index 5b6bf68e7..2c5850099 100644 --- a/include/ceres/loss_function.h +++ b/include/ceres/loss_function.h @@ -75,10 +75,11 @@ #ifndef CERES_PUBLIC_LOSS_FUNCTION_H_ #define CERES_PUBLIC_LOSS_FUNCTION_H_ +#include "glog/logging.h" #include "ceres/internal/macros.h" #include "ceres/internal/scoped_ptr.h" #include "ceres/types.h" -#include "glog/logging.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -395,4 +396,6 @@ class CERES_EXPORT LossFunctionWrapper : public LossFunction { } // namespace ceres +#include "ceres/internal/disable_warnings.h" + #endif // CERES_PUBLIC_LOSS_FUNCTION_H_ diff --git a/include/ceres/normal_prior.h b/include/ceres/normal_prior.h index 530e65253..df6650545 100644 --- a/include/ceres/normal_prior.h +++ b/include/ceres/normal_prior.h @@ -36,6 +36,7 @@ #include "ceres/cost_function.h" #include "ceres/internal/eigen.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -72,4 +73,6 @@ class CERES_EXPORT NormalPrior: public CostFunction { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_NORMAL_PRIOR_H_ diff --git a/include/ceres/problem.h b/include/ceres/problem.h index 5881677a8..b1cb99a69 100644 --- a/include/ceres/problem.h +++ b/include/ceres/problem.h @@ -39,11 +39,12 @@ #include #include +#include "glog/logging.h" #include "ceres/internal/macros.h" #include "ceres/internal/port.h" #include "ceres/internal/scoped_ptr.h" #include "ceres/types.h" -#include "glog/logging.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -466,4 +467,6 @@ class CERES_EXPORT Problem { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_PROBLEM_H_ diff --git a/include/ceres/solver.h b/include/ceres/solver.h index fc70073ec..a2d983485 100644 --- a/include/ceres/solver.h +++ b/include/ceres/solver.h @@ -40,6 +40,7 @@ #include "ceres/iteration_callback.h" #include "ceres/ordered_groups.h" #include "ceres/types.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -957,4 +958,6 @@ CERES_EXPORT void Solve(const Solver::Options& options, } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_SOLVER_H_ diff --git a/include/ceres/types.h b/include/ceres/types.h index ff31d4530..9e9124655 100644 --- a/include/ceres/types.h +++ b/include/ceres/types.h @@ -40,6 +40,7 @@ #include #include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -475,4 +476,6 @@ CERES_EXPORT bool IsDenseLinearAlgebraLibraryTypeAvailable( } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_TYPES_H_