Where c is a set of feature attributes (how to disable) with gcc

I'm working with code from the core GNU utils and find that the void usage () function appears to be set with the "noreturn" attribute. Well, I'm changing the function and I want it to return (I removed the exit () call). The compiler still complains about the "noreturn" function returning and when using the Eclipse CDT debugger, when doing a step the code is abnormal - I am missing lines of code. I don't see the feature being set in the .c file, and there is no .h file for that .c file.

Df.c. I renamed the df_call.c file. How can the compiler find this attribute? How can I turn it off?

Thank.

======= Thanks to all contributors for their help! Short answer: "The use () function found in GNUutils 7.4 is prototyped in system.h as' void usage (int status) ATTRIBUTE_NORETURN '. Going to" empty usage (int status); / ATTRIBUTE_NORETURN; /' solved the problem for me, but leaves the problem with the modified system.h.

Long answer: The GNU c compiler supports assigning attributes to functions (see http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html ), one of which is "no return". The syntax is " attribute ((noreturn))" (see http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax ) but the macro for ATTRIBUTE_NORETURN is often used. If the attribute is set, in which case one tries to return from the function, the executable is compiled with the complaint, but compiled and run. However, it will behave unexpectedly (missing src lines in my case, possibly due to optimization). The debugger in Eclipse CDT actually jumps over lines of code, making the developer question his feelings.

+2


source to share


2 answers


I would like to suggest preprocessing the source file so that you can get the entire contents of the translation unit. From there, I would usage

look to see where the gcc attribute might be coming from. You should also check for possible gcc command line arguments and / or macros that might affect your function declaration.



+1


source


run gcc -E

instead gcc -c

and see the results. With luck, it will be clear where the noreturn attribute comes from.

Another alternative would be to do what I am doing, which avoids the use of gcc-specific extensions.



gcc -std=c99 -pedantic

      

can tame the beast.

0


source







All Articles