From cf5d6e041ef502ad871af30406284ca4ce7ccd76 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 10 Apr 2014 19:58:14 +0200 Subject: [PATCH] Use pragmas to fix warnings --- Installation/include/CGAL/config.h | 20 ++++++++++++++++--- Mesh_3/include/CGAL/Mesh_3/config.h | 19 ++++++++++++++++-- .../include/CGAL/Mesh_3/global_parameters.h | 8 +++++++- Mesh_3/include/CGAL/Mesh_criteria_3.h | 10 ++++++++++ Mesh_3/include/CGAL/make_mesh_3.h | 9 +++++++++ Mesh_3/include/CGAL/refine_mesh_3.h | 9 ++++++++- 6 files changed, 68 insertions(+), 7 deletions(-) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 9c7e2953bf9..08d34cc5a28 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -313,11 +313,17 @@ using std::max; #ifndef __has_builtin #define __has_builtin(x) 0 // Compatibility with non-clang compilers. #endif +#ifndef __has_attribute + #define __has_attribute(x) 0 // Compatibility with non-clang compilers. +#endif +#ifndef __has_warning + #define __has_warning(x) 0 // Compatibility with non-clang compilers. +#endif // Macro to trigger deprecation warnings #ifdef CGAL_NO_DEPRECATION_WARNINGS # define CGAL_DEPRECATED -#elif defined(__GNUC__) +#elif defined(__GNUC__) || __has_attribute(__deprecated__) # define CGAL_DEPRECATED __attribute__((__deprecated__)) #elif defined (_MSC_VER) && (_MSC_VER > 1300) # define CGAL_DEPRECATED __declspec(deprecated) @@ -327,14 +333,14 @@ using std::max; // Macro to specify a 'noreturn' attribute. -#ifdef __GNUG__ +#if defined(__GNUG__) || __has_attribute(__noreturn__) # define CGAL_NORETURN __attribute__ ((__noreturn__)) #else # define CGAL_NORETURN #endif // Macro to specify a 'unused' attribute. -#ifdef __GNUG__ +#if defined(__GNUG__) || __has_attribute(__unused__) # define CGAL_UNUSED __attribute__ ((__unused__)) #else # define CGAL_UNUSED @@ -361,6 +367,14 @@ using std::max; # endif #endif +// Helper macros to disable macros +#if defined(__clang__) || (BOOST_GCC >= 40600) +# define CGAL_PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push") +# define CGAL_PRAGMA_DIAG_POP _Pragma("GCC diagnostic pop") +#else +# define CGAL_PRAGMA_DIAG_PUSH +# define CGAL_PRAGMA_DIAG_POP +#endif namespace CGAL { diff --git a/Mesh_3/include/CGAL/Mesh_3/config.h b/Mesh_3/include/CGAL/Mesh_3/config.h index ddb58259c3c..ddff7b1be40 100644 --- a/Mesh_3/include/CGAL/Mesh_3/config.h +++ b/Mesh_3/include/CGAL/Mesh_3/config.h @@ -20,8 +20,6 @@ #ifndef CGAL_MESH_3_CONFIG_H #define CGAL_MESH_3_CONFIG_H 1 -#include - #include //#define CGAL_MESH_3_VERBOSE 1 @@ -64,4 +62,21 @@ # endif #endif +#if defined(__clang__) || (BOOST_GCC >= 40600) +# define CGAL_MESH_3_IGNORE_UNUSED_VARIABLES \ + _Pragma("GCC diagnostic ignored \"-Wunused-variable\"") +#else +# define CGAL_MESH_3_IGNORE_UNUSED_VARIABLES +#endif +#if __has_warning("-Wunneeded-internal-declaration") +# define CGAL_MESH_3_IGNORE_UNUSED_INTERNAL_DECLARATION \ + _Pragma("clang diagnostic ignored \"-Wunneeded-internal-declaration\"") +#else +# define CGAL_MESH_3_IGNORE_UNUSED_INTERNAL_DECLARATION +#endif + +#define CGAL_MESH_3_IGNORE_BOOST_PARAMETER_NAME_WARNINGS \ + CGAL_MESH_3_IGNORE_UNUSED_VARIABLES \ + CGAL_MESH_3_IGNORE_UNUSED_INTERNAL_DECLARATION + #endif // CGAL_MESH_3_CONFIG_H diff --git a/Mesh_3/include/CGAL/Mesh_3/global_parameters.h b/Mesh_3/include/CGAL/Mesh_3/global_parameters.h index fea5a71d62f..722dbb9973b 100644 --- a/Mesh_3/include/CGAL/Mesh_3/global_parameters.h +++ b/Mesh_3/include/CGAL/Mesh_3/global_parameters.h @@ -55,7 +55,12 @@ private: { Class(double d) : Base(d) { precondition(d); } }; \ inline Class function(double d) { return Class(d); } -BOOST_PARAMETER_NAME( c3t3 ) +// see +CGAL_PRAGMA_DIAG_PUSH +// see +CGAL_MESH_3_IGNORE_BOOST_PARAMETER_NAME_WARNINGS + +BOOST_PARAMETER_NAME( c3t3 ); BOOST_PARAMETER_NAME( domain ) BOOST_PARAMETER_NAME( criteria ) @@ -75,6 +80,7 @@ BOOST_PARAMETER_NAME( (dump_after_glob_opt_prefix, tag ) dump_after_glob_opt_pre BOOST_PARAMETER_NAME( (dump_after_perturb_prefix, tag ) dump_after_perturb_prefix_) BOOST_PARAMETER_NAME( (dump_after_exude_prefix, tag ) dump_after_exude_prefix_) +CGAL_PRAGMA_DIAG_POP } // end namespace parameters diff --git a/Mesh_3/include/CGAL/Mesh_criteria_3.h b/Mesh_3/include/CGAL/Mesh_criteria_3.h index d2088c5ee02..6e1feb3a666 100644 --- a/Mesh_3/include/CGAL/Mesh_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_criteria_3.h @@ -27,6 +27,7 @@ #ifndef CGAL_MESH_CRITERIA_3_H #define CGAL_MESH_CRITERIA_3_H +#include #include #include #include @@ -35,6 +36,12 @@ namespace CGAL { namespace parameters { + +// see +CGAL_PRAGMA_DIAG_PUSH +// see +CGAL_MESH_3_IGNORE_BOOST_PARAMETER_NAME_WARNINGS + BOOST_PARAMETER_NAME( (edge_size, tag) edge_size_ ) BOOST_PARAMETER_NAME( (edge_sizing_field, tag) edge_sizing_field_ ) BOOST_PARAMETER_NAME( (facet_angle, tag) facet_angle_ ) @@ -47,6 +54,9 @@ namespace parameters { BOOST_PARAMETER_NAME( (cell_size, tag) cell_size_ ) BOOST_PARAMETER_NAME( (cell_sizing_field, tag) cell_sizing_field_ ) BOOST_PARAMETER_NAME( (sizing_field, tag) sizing_field_ ) + +CGAL_PRAGMA_DIAG_POP + } // end namespace parameters namespace internal { diff --git a/Mesh_3/include/CGAL/make_mesh_3.h b/Mesh_3/include/CGAL/make_mesh_3.h index 2583f69ee82..41f83852532 100644 --- a/Mesh_3/include/CGAL/make_mesh_3.h +++ b/Mesh_3/include/CGAL/make_mesh_3.h @@ -25,6 +25,7 @@ #ifndef CGAL_MAKE_MESH_3_H #define CGAL_MAKE_MESH_3_H +#include #include #include #include @@ -113,7 +114,15 @@ namespace parameters { // ----------------------------------- // Parameters // ----------------------------------- + +// see +CGAL_PRAGMA_DIAG_PUSH +// see +CGAL_MESH_3_IGNORE_BOOST_PARAMETER_NAME_WARNINGS + BOOST_PARAMETER_NAME( features_param ) + +CGAL_PRAGMA_DIAG_POP } // end namespace parameters::internal diff --git a/Mesh_3/include/CGAL/refine_mesh_3.h b/Mesh_3/include/CGAL/refine_mesh_3.h index b3bfd6c55f8..0c4cc81a56f 100644 --- a/Mesh_3/include/CGAL/refine_mesh_3.h +++ b/Mesh_3/include/CGAL/refine_mesh_3.h @@ -26,6 +26,7 @@ #define CGAL_REFINE_MESH_3_H #include +#include #include #include #include @@ -314,6 +315,11 @@ namespace parameters { CGAL_MESH_BOOLEAN_PARAMETER(Reset,reset_c3t3,no_reset_c3t3) // CGAL_MESH_BOOLEAN_PARAMETER defined in +// see +CGAL_PRAGMA_DIAG_PUSH +// see +CGAL_MESH_3_IGNORE_BOOST_PARAMETER_NAME_WARNINGS + // ----------------------------------- // Parameters // ----------------------------------- @@ -323,7 +329,8 @@ namespace parameters { BOOST_PARAMETER_NAME( lloyd_param ) BOOST_PARAMETER_NAME( reset_param ) BOOST_PARAMETER_NAME( mesh_options_param ) - + +CGAL_PRAGMA_DIAG_POP } // end namespace parameters