What's The Deal With __attribute and __attribute__?

This is a discussion on What's The Deal With __attribute and __attribute__? within the C++ Programming forums, part of the General Programming Boards category; I heard you could utilize in the g++ compiler the __attribute and __attribute__ keywords. What's the difference between these two? ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21