3 ms·
Fortunately these days you're supposed to use __has_attribute, __has_extension, and __has_builtin. But I'm not sure if, overall, things have gotten better. For
by wahern 7y ago
Fortunately these days you're supposed to use __has_attribute, __has_extension, and __has_builtin. But I'm not sure if, overall, things have gotten better.
For example, overly eager diagnostic warnings have come at the cost of an increased need to disable diagnostics--perfectly standard-compliant code, not to mention widely supported extensions, will often trigger diagnostics with -Wall. You can disable those inline (and I try, because good luck trying to figure out what's the equivalent of CFLAGS in the build pipeline du jour, or simply expecting the user to figure it out), but they often have different names in different compilers and sometimes you have to resort to version guards to maintain a diagnostic-free build out-of-the-box.
Also, the default compiler on RHEL7 is GCC 4.8, which lacks __has_attribute and friends, among other things. EOL for RHEL7 is 2024! And __has_builtin didn't even come around until GCC 10, and didn't work reliably prior to clang 11.