LINUX programming

Moderators: ITA
Number of threads: 1339
Number of posts: 2924

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
__attribute__ in C programing Posted by Deepak on 27 Mar 2001 at 5:23 AM
Does anybody know what the __attribute__ in certain .c and .h files in Linux means?
Know where I can get additional info?

Thanks,
Deepak

Report
Re: __attribute__ in C programing Posted by gautam on 27 Mar 2001 at 10:02 AM
I have never seen __attribute__ in a c or .h file, is this in a program ? or is this in the standard gcc header files ? If its in a program, look into the code, and check.

: Does anybody know what the __attribute__ in certain .c and .h files in Linux means?
: Know where I can get additional info?
:
: Thanks,
: Deepak
:


Report
Re: __attribute__ in C programing Posted by Deepak on 27 Mar 2001 at 9:37 PM
: I have never seen __attribute__ in a c or .h file, is this in a program ? or is this in the standard gcc header files ? If its in a program, look into the code, and check.
:
: : Does anybody know what the __attribute__ in certain .c and .h files in Linux means?
: : Know where I can get additional info?
: :
: : Thanks,
: : Deepak
: :
:
:

Do a grep for __attribute__ in the source files of Linux components.

D


Report
Re: __attribute__ in C programing Posted by Deepak on 28 Mar 2001 at 6:38 AM
: : I have never seen __attribute__ in a c or .h file, is this in a program ? or is this in the standard gcc header files ? If its in a program, look into the code, and check.
: :
: : : Does anybody know what the __attribute__ in certain .c and .h files in Linux means?
: : : Know where I can get additional info?
: : :
: : : Thanks,
: : : Deepak
: : :
: :
: :
:
: Do a grep for __attribute__ in the source files of Linux components.
:
: D
:
:

Check out http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#SEC84

D


Report
Re: __attribute__ in C programing Posted by gautam on 28 Mar 2001 at 9:23 AM
Thank you,

Actually I was searching for this sort of stuff for my code in C, and was wondering what the option was for compiling in 1byte boundary.

: : : I have never seen __attribute__ in a c or .h file, is this in a program ? or is this in the standard gcc header files ? If its in a program, look into the code, and check.
: : :
: : : : Does anybody know what the __attribute__ in certain .c and .h files in Linux means?
: : : : Know where I can get additional info?
: : : :
: : : : Thanks,
: : : : Deepak
: : : :
: : :
: : :
: :
: : Do a grep for __attribute__ in the source files of Linux components.
: :
: : D
: :
: :
:
: Check out http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#SEC84
:
: D
:
:


Report
Re: __attribute__ in C programing Posted by ertzog on 18 Dec 2001 at 12:25 PM
: Does anybody know what the __attribute__ in certain .c and .h files in Linux means?

: Know where I can get additional info?



It is quite easy: info gcc.

The keyword __attribute__ ((lalala)) tells gcc,

that function is not just a common function. It can make

many different things with it, due the lalala.

Read the section "C extensions"->"Function attributes"


Report
Re: __attribute__ in C programing Posted by aliancemd on 5 Dec 2011 at 1:04 AM
The article is since 2001 but I will answer anyway.

Take for example this code:
struct Packaging {
    char c;
    int i;
} Packaging;

sizeof(Packaging) will be 8 Bytes.

or you could do:
#pragma pack(push)
#pragma pack(1)

struct Packaging {
    char c;
    int i;
} Packaging;

#pragma pack(pop)

sizeof(Packaging) will be 5 Bytes because of aliasing.

We can use __attribute__ instead of #pragma, like this:
struct Packaging {
    char c;
    int i;
} __attribute__((packed)) Packaging;

It will have the same effect as pragma.
And there are a lot of other uses for __attribute__.
Report
Re: __attribute__ in C programing Posted by hyphentech on 27 Jun 2012 at 2:15 AM
Hi,

I have just noticed that all my files have the attribute C. I've been running XP on the machine for several years, and I never noticed that before.


Website Design Company | Graphics Design Services
Report
Re: __attribute__ in C programing Posted by hyphentech on 27 Jun 2012 at 2:17 AM
Hi,

I have just noticed that all my files have the attribute C. I've been running XP on the machine for several years, and I never noticed that before.





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.