mirror of https://github.com/CGAL/cgal
Add the macro CGAL_USE_TYPE(), and a test for <CGAL/use.h>
This commit is contained in:
parent
ee5b4683d0
commit
5ddbb68176
|
|
@ -25,10 +25,15 @@ namespace CGAL { namespace internal {
|
|||
template < typename T > inline
|
||||
void use(const T&) {}
|
||||
|
||||
template<typename> void use_type() {}
|
||||
|
||||
} }
|
||||
|
||||
// CGAL_USE() is a macro which aims at removing "variable is unused" warnings.
|
||||
|
||||
/// CGAL_USE() is a macro which aims at removing "variable is unused" warnings.
|
||||
#define CGAL_USE(x) ::CGAL::internal::use(x)
|
||||
|
||||
/// CGAL_USE_TYPE() is a macro which aims at removing "typedef locally
|
||||
/// defined but not used" warnings.
|
||||
#define CGAL_USE_TYPE(T) ::CGAL::internal::use_type<T>()
|
||||
|
||||
#endif // CGAL_USE_H
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ if ( CGAL_FOUND )
|
|||
|
||||
create_single_source_cgal_program( "deprecation_warning.cpp" )
|
||||
|
||||
create_single_source_cgal_program( "test_use_h.cpp" )
|
||||
|
||||
create_link_to_program(CGAL)
|
||||
|
||||
if ( WITH_CGAL_Core )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
#include <CGAL/use.h>
|
||||
|
||||
template <typename T>
|
||||
struct Foo {
|
||||
typedef typename T::fake fake;
|
||||
// Fake typedef to check that Foo<double> is not instantiated.
|
||||
};
|
||||
|
||||
int test_use_type()
|
||||
{
|
||||
typedef Foo<double> type;
|
||||
|
||||
// If the following line is commented, g++-4.8 -Wall displays that
|
||||
// warning:
|
||||
// typedef ‘type’ locally defined but not used [-Wunused-local-typedefs]
|
||||
CGAL_USE_TYPE(type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_use() {
|
||||
int unused;
|
||||
|
||||
// If the following line is commented, g++-4.8 -Wall displays that
|
||||
// warning:
|
||||
// unused variable ‘unused’ [-Wunused-variable]
|
||||
CGAL_USE(unused);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
return test_use_type() + test_use();
|
||||
}
|
||||
Loading…
Reference in New Issue