public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Robert P. J. Day" <rpjday@mindspring.com>
To: GCC help list <gcc-help@gcc.gnu.org>
Subject: what's the point of a return type with "__attribute__((noreturn))"?
Date: Sat, 26 May 2007 11:56:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.0705260634120.18660@localhost.localdomain> (raw)


  at the moment, we're having an animated discussion over at the linux
kernel mailing list regarding proper usage of attributes, so i'd like
to ask a few questions about how people tend to use them.  as
examples, let's say i wanted to tag a function as deprecated.

  first, i'm assuming that the function declaration (if there is one)
can be written as any one of:

__attribute__((deprecated)) int fubar(void);
int __attribute__((deprecated)) fubar(void);
int fubar(void) __attribute__((deprecated));

  that is, the attribute placement in the declaration is flexible,
even though it appears that that last form seems to be the most
popular, is that right?

  next, once i set an attribute on a function *declaration*, there's
no need to also set it on the subsequent function *definition*.  i
mean, i *could* but that would be redundant, correct?  however, in the
case where there is *only* a function definition, i could write that
definition in one of two ways:

__attribute__((deprecated)) int fubar(void) { ... }
int __attribute__((deprecated)) fubar(void) { ... }

  and, again, that second form seems to be more popular.  so far, so
good?  (just to clarify this in my mind, most of the declarations i've
seen have the attribute at the end, while most definitions put the
attribute between the return type and the routine name.)

  the big issue, though, involves "__attribute__((noreturn))".
the gcc manual on this page:

http://www.delorie.com/gnu/docs/gcc/gcc_55.html

shows the following snippet of code:

...
void fatal () __attribute__ ((noreturn));

void
fatal (...)
{
  ... /* Print error message. */ ...
  exit (1);
}
...

to keep a long question short, even though a "noreturn" routine
doesn't return, is it still traditional to declare it with a return
type of "void"?  thanks.

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

             reply	other threads:[~2007-05-26 11:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-26 11:56 Robert P. J. Day [this message]
2007-05-26 20:29 ` John (Eljay) Love-Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0705260634120.18660@localhost.localdomain \
    --to=rpjday@mindspring.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).