Skip to content

Rework the warning suppression macros #5424

Open
@derobins

Description

@derobins

The macros in H5warnings.h have several flaws:

  • The compiler name(s) appear in the macros, which means that we sometimes either have multiple macro lines around problematic code or we wind up with "combo" macros like the gcc-clang macros that will be awkward to extend to new compilers.
  • The macros are simple replacements for individual pragma lines, so any ifdef complications have to be handled in the library code, not H5warnings.h. These ifdefs and the comments that explain them will have to be duplicated throughout the library code.
  • The name of the suppressed warning may not be very informative. For example, passing MPI_STATUSES_IGNORE as a parameter to MPI calls can raise spurious stringop-overflow warnings w/ gcc. It'd be nice to have a warning suppression that clearly indicated the nature of the (non-)problem.

We should replace the existing scheme with one that uses a wider set of macros that hide ifdef complexity and can be more easily extended to other compilers (e.g., MSVC).

Example:

/* Disable warnings concerning non-standard extensions, like F16 */
/* clang */
#if defined(__clang__)
#define H5_WARN_NONSTD_SUFFIX_OFF H5_WARN_OFF("pedantic")
#define H5_WARN_NONSTD_SUFFIX_ON  H5_WARN_ON("pedantic")
/* gcc 14+ */
#elif defined(__GNUC__) && __GNUC__ >= 14
#define H5_WARN_NONSTD_SUFFIX_OFF H5_WARN_OFF("c11-c23-compat")
#define H5_WARN_NONSTD_SUFFIX_ON  H5_WARN_ON("c11-c23-compat")
/* gcc 9-13 */
#elif defined(__GNUC__) && __GNUC__ >= 9
#define H5_WARN_NONSTD_SUFFIX_OFF H5_WARN_OFF("c11-c2x-compat")
#define H5_WARN_NONSTD_SUFFIX_ON  H5_WARN_ON("c11-c2x-compat")
#else
/* Everything else */
#define H5_WARN_NONSTD_SUFFIX_OFF
#define H5_WARN_NONSTD_SUFFIX_ON
#endif

Metadata

Metadata

Assignees

Labels

Component - C LibraryCore C library issues (usually in the src directory)Priority - 2. MediumIt would be nice to have this in the next release

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions