__attribute__ error ("message")
Jonny Grant
jg@jguk.org
Fri Mar 31 21:54:25 GMT 2023
Hello
May I check, does this attribute error output the error message usually?
My example links fine without any warnings or errors.
Maybe I am misunderstanding it. I am sharing a simple program below and godbolt trunk example.
I only get to see the error message if I don't implement the function and get a link failure.
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
error ("message")
warning ("message")
If the error or warning attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, an error or warning (respectively) that includes message is diagnosed.
https://godbolt.org/z/n849GPTjj
void compile_abort() __attribute__((error("compile abort")));
void compile_abort()
{
__builtin_abort();
}
int main()
{
compile_abort();
}
More information about the Gcc-help
mailing list