Some macros, such as `HEDLEY_STATIC_ASSERT` [expand to nothing](https://github.com/nemequ/hedley/blob/8fb0604a8095f6c907378cc3f0391520ae843f6f/hedley.h#L1870) when they are not supported by a particular platform. This can result in hard-to-fix warnings when using `-Wpedantic` on clang or gcc. Specifically, for C++11 and above, the following requires a semicolon at the end: ```c++ HEDLEY_STATIC_ASSERT(true, ""); ``` See https://godbolt.org/z/4dYWveMaj However, under `-Wpedantic`, the same line will raise a warning on C++98 because the macro expands to nothing, leaving a lone semicolon on the line. See https://godbolt.org/z/Wbhcjsqvz I wonder if it would be helpful to have the 'empty' version of the macro actually expand to something the requires a semi-colon at the end, so that it behaves the same as the normal version. Looking at other libraries, such as Doctest, [the preferred technique](https://github.com/onqtam/doctest/blob/4d8716f1efc1d14aa736ef52ee727bd4204f4c40/doctest/doctest.h#L1955) seems to be to define a `typedef` with a unique name, which is effectively a no-op. Something along the lines of this: ```c++ #define HEDLEY_STATIC_ASSERT(expr, message) \ typedef int HEDLEY_UNIQUE_NAME(HEDLEY_ANON_FOR_SEMICOLON_) ``` where `HEDLEY_UNIQUE_NAME` is a macro which expands to a unique string: ```c++ #ifdef __COUNTER__ # define HEDLEY_UNIQUE_NAME(name) HEDLEY_CONCAT(name, __COUNTER__) #else # define HEDLEY_UNIQUE_NAME(name) HEDLEY_CONCAT(name, __LINE__) #endif ``` Here's an example of what it does: https://godbolt.org/z/ddn4bjPjM The use of `__COUNTER__` if it is available is helpful for cases where the macro appears more than once on a single line, because C [does not allow repeated typedefs](https://stackoverflow.com/questions/8594954/repeated-typedefs-invalid-in-c-but-valid-in-c). They're apparently OK in C++ though.
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be still under discussion. The issue was opened by aharrison24 and has received 2 comments.