| gnu::warning(3attr) | gnu::warning(3attr) |
NAME¶
gnu::warning, gnu::error - diagnose function calls not removed by optimizations
SYNOPSIS¶
[[gnu::warning(msg)]] [[gnu::error(msg)]]
DESCRIPTION¶
This attribute can be applied to a function. If the function call is not removed by optimizations, a diagnostic is emitted. The diagnostic contains the message msg and the location of the call in the source code.
[[gnu::error()]] terminates the compilation after emitting the diagnostic.
VERSIONS¶
- __attribute__((warning(msg)))
- __attribute__((error(msg)))
STANDARDS¶
GNU.
HISTORY¶
gcc 4.3, g++ 4.3, clang 14, clang++ 14.
CAVEATS¶
This diagnostic is emitted by the compiler, so it doesn't take into account linker optimizations.
EXAMPLES¶
#include <stdlib.h>
[[gnu::warning("foo")]] void dontcall(void);
int
main(void)
{
dontcall(); // Warning.
if (0)
dontcall(); // No warning.
exit(EXIT_SUCCESS);
}
| 2025-11-11 | Linux man-pages (unreleased) |