Thread: What's The Deal With __attribute and __attribute__?

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    30

    What's The Deal With __attribute and __attribute__?

    I heard you could utilize in the g++ compiler the __attribute and __attribute__ keywords. What's the difference between these two? If __attribute__((noreturn)) can be used on a void function or a function that never returns to optimize the compiler/clear up code, then why isn't everyone using it?!?

    const int init()__attribute__((const))
    void foo()__attribute__((noreturn))

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Did you read the GCC manual before asking question 1?

    > then why isn't everyone using it?!?
    Well
    a) very few functions can be classed as noreturn to begin with
    b) all attributes are GCC specific, so have no place in portable code
    c) people are lazy bums
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deal or No Deal Proogram
    By shel5210 in forum C Programming
    Replies: 1
    Last Post: 03-28-2010, 08:04 PM
  2. Deal or No Deal listbox prob
    By kryptkat in forum Windows Programming
    Replies: 5
    Last Post: 03-30-2009, 06:53 PM
  3. Replies: 5
    Last Post: 09-18-2008, 02:57 PM
  4. Replies: 2
    Last Post: 04-26-2008, 04:43 AM