Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is __attribute__?

Status
Not open for further replies.

maluk

Programmer
Oct 12, 2002
79
SG
What is an __attribute__?
What is this good for?
What things similar to __attribute__ should I know in gcc?

Rome did not create a great empire by having meetings, they did it by
killing all those who opposed them.

- janvier -
 
> What is an __attribute__?
GCC Manual
It's a bit of magic which allows you to tell the compiler something about the code.

> What is this good for?
See the manual.
For example, the "packed" attribute is similar to the Microsoft "#pragma pack"
Attributes are both more extensive and more useful than pragmas though.

> What things similar to __attribute__ should I know in gcc?
See the manual.
You will notice that attributes are part of the "C Extensions" part of the manual. This means no other compiler supports them (or will support them in a different way).

How much of it is useful really depends on what you are doing. All of it is useful to somebody at some point, but you have to be doing something fairly unusual before any of the extensions become "a must".

By and large, you should be trying to write most of your code using only ANSI-C (which is portable).


--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top