Skip to content

Commit

Permalink
Add configure test for diagnostic _Pragma() use inside functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jedbrown committed May 29, 2011
1 parent ac7820a commit 02dd59a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,16 @@ add_subdirectory (src)
if (Dohp_BUILD_SANDBOX)
add_subdirectory (${Dohp_SOURCE_DIR}/sandbox)
endif (Dohp_BUILD_SANDBOX)

include (CheckCSourceCompiles) # The name is misleading, this also tries to link
check_c_source_compiles ("
#define PragmaQuote(a) _Pragma(#a)
#define PragmaGCC(a) PragmaQuote(GCC a)
int main(int argc,char *argv[]) {
PragmaGCC(diagnostic ignored \"-Wconversion\")
char c = (int)argv[0][0] + argv[argc-1][0];
return c;
}" dHAVE_PRAGMA_GCC)
if (dHAVE_PRAGMA_GCC)
set (dHAVE_PRAGMA_GCC TRUE)
endif ()
1 change: 1 addition & 0 deletions dohpconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
#cmakedefine dUSE_PARALLEL_HDF5
#cmakedefine dUSE_LOG_FINEGRAIN
#cmakedefine dUSE_VALGRIND
#cmakedefine dHAVE_PRAGMA_GCC

#endif
6 changes: 5 additions & 1 deletion include/dohp.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#include <petscsys.h>

#define dPragmaQuote(a) _Pragma(#a)
#define dPragmaGCC(a) dPragmaQuote(GCC a)
#if defined dHAVE_PRAGMA_GCC
# define dPragmaGCC(a) dPragmaQuote(GCC a)
#else
# define dPragmaGCC(a)
#endif

#if defined dUSE_VALGRIND
# include <valgrind/memcheck.h>
Expand Down

0 comments on commit 02dd59a

Please sign in to comment.