diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b57e9bf27b5..5ce3b7cac18 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -864,6 +864,7 @@ set (H5_PUBLIC_HEADERS set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5private.h ${HDF5_SRC_DIR}/H5timer.h + ${HDF5_SRC_DIR}/H5warnings.h ${HDF5_SRC_DIR}/H5Apkg.h ${HDF5_SRC_DIR}/H5Aprivate.h diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 2838ed00bff..56ee7b1a198 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -24,6 +24,8 @@ #include "hdf5.h" +#include "H5warnings.h" + #ifndef false #define false 0 #endif @@ -40,34 +42,6 @@ #define my_strdup strdup #endif -/* Macros for enabling/disabling particular GCC / clang warnings - * - * These are duplicated in H5private.h. If you make changes here, be sure to - * update those as well. - * - * (see the following web-sites for more info: - * http://www.dbp-consulting.com/tutorials/SuppressingGCCWarnings.html - * http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas - */ -#define H5_MULTI_DIAG_JOINSTR(x, y) x y -#define H5_MULTI_DIAG_DO_PRAGMA(x) _Pragma(#x) -#define H5_MULTI_DIAG_PRAGMA(x) H5_MULTI_DIAG_DO_PRAGMA(GCC diagnostic x) - -#define H5_MULTI_DIAG_OFF(x) \ - H5_MULTI_DIAG_PRAGMA(push) H5_MULTI_DIAG_PRAGMA(ignored H5_MULTI_DIAG_JOINSTR("-W", x)) -#define H5_MULTI_DIAG_ON(x) H5_MULTI_DIAG_PRAGMA(pop) - -/* Macros for enabling/disabling particular GCC / clang warnings. - * These macros should be used for warnings supported by both gcc and clang. - */ -#if (((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__) -#define H5_MULTI_GCC_CLANG_DIAG_OFF(x) H5_MULTI_DIAG_OFF(x) -#define H5_MULTI_GCC_CLANG_DIAG_ON(x) H5_MULTI_DIAG_ON(x) -#else -#define H5_MULTI_GCC_CLANG_DIAG_OFF(x) -#define H5_MULTI_GCC_CLANG_DIAG_ON(x) -#endif - /* Loop through all mapped files */ #define UNIQUE_MEMBERS_CORE(MAP, ITER, SEEN, LOOPVAR) \ { \ @@ -2032,7 +2006,7 @@ compute_next(H5FD_multi_t *file) * tmp in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_MULTI_GCC_CLANG_DIAG_OFF("format-nonliteral") +H5_GCC_CLANG_DIAG_OFF("format-nonliteral") static int open_members(H5FD_multi_t *file) { @@ -2070,7 +2044,7 @@ open_members(H5FD_multi_t *file) return 0; } -H5_MULTI_GCC_CLANG_DIAG_ON("format-nonliteral") +H5_GCC_CLANG_DIAG_ON("format-nonliteral") /*------------------------------------------------------------------------- * Function: H5FD_multi_delete @@ -2081,7 +2055,7 @@ H5_MULTI_GCC_CLANG_DIAG_ON("format-nonliteral") * *------------------------------------------------------------------------- */ -H5_MULTI_GCC_CLANG_DIAG_OFF("format-nonliteral") +H5_GCC_CLANG_DIAG_OFF("format-nonliteral") static herr_t H5FD_multi_delete(const char *filename, hid_t fapl_id) { @@ -2135,7 +2109,7 @@ H5FD_multi_delete(const char *filename, hid_t fapl_id) return 0; } /* end H5FD_multi_delete() */ -H5_MULTI_GCC_CLANG_DIAG_ON("format-nonliteral") +H5_GCC_CLANG_DIAG_ON("format-nonliteral") /*------------------------------------------------------------------------- * Function: H5FD_multi_ctl diff --git a/src/H5private.h b/src/H5private.h index 42a6dccb22b..a7bab99c581 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -152,6 +152,9 @@ #endif /*H5_HAVE_WIN32_API*/ +/* Macros for suppressing warnings */ +#include "H5warnings.h" + #ifndef F_OK #define F_OK 00 #define W_OK 02 @@ -519,63 +522,6 @@ #define LOCK_UN 0x08 #endif /* H5_HAVE_FLOCK */ -/* Macros for enabling/disabling particular GCC / clang warnings - * - * These are duplicated in H5FDmulti.c (we don't want to put them in the - * public header and the multi VFD can't use private headers). If you make - * changes here, be sure to update those as well. - * - * (see the following web-sites for more info: - * http://www.dbp-consulting.com/tutorials/SuppressingGCCWarnings.html - * http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas - */ -#define H5_DIAG_JOINSTR(x, y) x y -#define H5_DIAG_DO_PRAGMA(x) _Pragma(#x) -#define H5_DIAG_PRAGMA(x) H5_DIAG_DO_PRAGMA(GCC diagnostic x) - -/* Allow suppression of compiler diagnostics unless H5_SHOW_ALL_WARNINGS is - * defined (enabled with '--enable-show-all-warnings' configure option). - */ -#ifndef H5_SHOW_ALL_WARNINGS -#define H5_DIAG_OFF(x) H5_DIAG_PRAGMA(push) H5_DIAG_PRAGMA(ignored H5_DIAG_JOINSTR("-W", x)) -#define H5_DIAG_ON(x) H5_DIAG_PRAGMA(pop) -#else -#define H5_DIAG_OFF(x) -#define H5_DIAG_ON(x) -#endif - -/* Macros for enabling/disabling particular GCC-only warnings. - * These pragmas are only implemented usefully in gcc 4.6+ - */ -#if (((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) -#define H5_GCC_DIAG_OFF(x) H5_DIAG_OFF(x) -#define H5_GCC_DIAG_ON(x) H5_DIAG_ON(x) -#else -#define H5_GCC_DIAG_OFF(x) -#define H5_GCC_DIAG_ON(x) -#endif - -/* Macros for enabling/disabling particular clang-only warnings. - */ -#if defined(__clang__) -#define H5_CLANG_DIAG_OFF(x) H5_DIAG_OFF(x) -#define H5_CLANG_DIAG_ON(x) H5_DIAG_ON(x) -#else -#define H5_CLANG_DIAG_OFF(x) -#define H5_CLANG_DIAG_ON(x) -#endif - -/* Macros for enabling/disabling particular GCC / clang warnings. - * These macros should be used for warnings supported by both gcc and clang. - */ -#if (((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__) -#define H5_GCC_CLANG_DIAG_OFF(x) H5_DIAG_OFF(x) -#define H5_GCC_CLANG_DIAG_ON(x) H5_DIAG_ON(x) -#else -#define H5_GCC_CLANG_DIAG_OFF(x) -#define H5_GCC_CLANG_DIAG_ON(x) -#endif - /* If necessary, create a typedef for library usage of the * _Float16 type to avoid issues when compiling the library * with the -pedantic flag or similar where we get warnings diff --git a/src/H5warnings.h b/src/H5warnings.h new file mode 100644 index 00000000000..ae0027ab629 --- /dev/null +++ b/src/H5warnings.h @@ -0,0 +1,77 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Macros for suppressing warnings + */ + +#ifndef H5warnings_H +#define H5warnings_H + +/* Macros for enabling/disabling particular GCC / clang warnings + * + * These are duplicated in H5FDmulti.c (we don't want to put them in the + * public header and the multi VFD can't use private headers). If you make + * changes here, be sure to update those as well. + * + * (see the following web-sites for more info: + * http://www.dbp-consulting.com/tutorials/SuppressingGCCWarnings.html + * http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas + */ +#define H5_DIAG_JOINSTR(x, y) x y +#define H5_DIAG_DO_PRAGMA(x) _Pragma(#x) +#define H5_DIAG_PRAGMA(x) H5_DIAG_DO_PRAGMA(GCC diagnostic x) + +/* Allow suppression of compiler diagnostics unless H5_SHOW_ALL_WARNINGS is + * defined (enabled with '--enable-show-all-warnings' configure option). + */ +#ifndef H5_SHOW_ALL_WARNINGS +#define H5_DIAG_OFF(x) H5_DIAG_PRAGMA(push) H5_DIAG_PRAGMA(ignored H5_DIAG_JOINSTR("-W", x)) +#define H5_DIAG_ON(x) H5_DIAG_PRAGMA(pop) +#else +#define H5_DIAG_OFF(x) +#define H5_DIAG_ON(x) +#endif + +/* Macros for enabling/disabling particular GCC-only warnings. + * These pragmas are only implemented usefully in gcc 4.6+ + */ +#if (((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) +#define H5_GCC_DIAG_OFF(x) H5_DIAG_OFF(x) +#define H5_GCC_DIAG_ON(x) H5_DIAG_ON(x) +#else +#define H5_GCC_DIAG_OFF(x) +#define H5_GCC_DIAG_ON(x) +#endif + +/* Macros for enabling/disabling particular clang-only warnings. + */ +#if defined(__clang__) +#define H5_CLANG_DIAG_OFF(x) H5_DIAG_OFF(x) +#define H5_CLANG_DIAG_ON(x) H5_DIAG_ON(x) +#else +#define H5_CLANG_DIAG_OFF(x) +#define H5_CLANG_DIAG_ON(x) +#endif + +/* Macros for enabling/disabling particular GCC / clang warnings. + * These macros should be used for warnings supported by both gcc and clang. + */ +#if (((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__) +#define H5_GCC_CLANG_DIAG_OFF(x) H5_DIAG_OFF(x) +#define H5_GCC_CLANG_DIAG_ON(x) H5_DIAG_ON(x) +#else +#define H5_GCC_CLANG_DIAG_OFF(x) +#define H5_GCC_CLANG_DIAG_ON(x) +#endif + +#endif /* H5warnings_H */