Note that there are some explanatory texts on larger screens.

plurals
  1. POwhere is c function attribute set (how to unset) with gcc
    primarykey
    data
    text
    <p>I am working with code from the GNU core utils, and find that the void usage() function is apparently set with the attribute "noreturn". Well, I am modifying the function, and I wish it to return (I removed the call to exit()). The compiler still complains that a "noreturn" function returns, and when using the Eclipse CDT debugger, stepping thorugh the code is anomolous - I skip over lines of code. I do not see the function be set in the .c file, and there is no .h file for this .c file.</p> <p>The file is df.c. I have renamed the file df_call.c. How can the compiler be finding this attribute? How can I unset it?</p> <p>Thanks. </p> <p>======= Thanks to all contributors for their help! The short answer is "the usage() function found in GNUutils 7.4 is prototyped in system.h as 'void usage (int status) ATTRIBUTE_NORETURN'. Changing to 'void usage (int status); /<em>ATTRIBUTE_NORETURN;</em>/' resolved the issue for me, but leaves the problem of a modified system.h.</p> <p>The long answer is: The GNU c compiler supports assigning attributes to functions (see <a href="http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html" rel="nofollow noreferrer">http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html</a>) one of which is "noreturn". The syntax is "<strong>attribute</strong> ((noreturn))" (see <a href="http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax" rel="nofollow noreferrer">http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax</a>) but is often macro'd to ATTRIBUTE_NORETURN. If the attribute is set, and in this case one tries to return from the function, the executable compiles with a complaint, but compiles and runs. It will, however, behave unexpectedly (skipping over src lines in my case, maybe due to the optimization). The debugger in Eclipse CDT actually jumps past lines of code, leading the developer to doubt his senses.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload