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
diff --git a/include/ceres/c_api.h b/include/ceres/c_api.h index 632542e..71f41fd 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 @@ } #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 2a12ba6..3f0087c 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 @@ } // 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 fee3e73..45292ec 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 @@ } // 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 b6e9a6a..245381a 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 @@ } // 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 687c958..d2d6289 100644 --- a/include/ceres/crs_matrix.h +++ b/include/ceres/crs_matrix.h
@@ -33,6 +33,7 @@ #include <vector> #include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -80,4 +81,6 @@ } // 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 0000000..78924de --- /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 0000000..1f477d8 --- /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 5eca392..237ada6 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 @@ } // 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 ecac5ba..3ab21fc 100644 --- a/include/ceres/local_parameterization.h +++ b/include/ceres/local_parameterization.h
@@ -34,6 +34,7 @@ #include <vector> #include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -188,4 +189,6 @@ } // 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 5b6bf68..2c58500 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 @@ } // 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 530e652..df66505 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 @@ } // 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 5881677..b1cb99a 100644 --- a/include/ceres/problem.h +++ b/include/ceres/problem.h
@@ -39,11 +39,12 @@ #include <set> #include <vector> +#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 @@ } // 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 fc70073..a2d9834 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 @@ } // 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 ff31d45..9e91246 100644 --- a/include/ceres/types.h +++ b/include/ceres/types.h
@@ -40,6 +40,7 @@ #include <string> #include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -475,4 +476,6 @@ } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_TYPES_H_