lkml.org 
[lkml]   [2000]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: __attribute__ , noreturn
On Mon Mar 13, 2000 at 04:44:16PM +0500, Tiger wrote:
> Can some one explain what exactly it does __attribute__ and what is
> noretun

gcc uses "__attribute__" to specify compiler directives instead of the
traditional "#pragma" since #pragma behaviors are totally unportable and cannot
be placed into macros. Consider this code:

#include<stdlib.h>
#include <stdio.h>

__attribute__ ((noreturn)) void message1(const char *msg)
{
printf(msg);
exit(0);
}


int main( void)
{
message1("Hello\n");
}


Without the __attribute__ ((noreturn)), the compiler would complain that
"control reaches end of non-void function" in main(). By using the attribute
we can give the compiler the hint that control will never go back to main(),
and it doesn't need to give a warning.

-Erik

--
Erik B. Andersen Web: http://www.xmission.com/~andersen/
email: andersee@debian.org
--This message was written using 73% post-consumer electrons--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.059 / U:0.772 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site