__attribute__ in C programing

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

Thanks,
Deepak

Comments

  • 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
    :


  • : 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


  • : : 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


  • 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
    :
    :


  • : 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"


  • The article is since 2001 but I will answer anyway.

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

    sizeof(Packaging) will be 8 Bytes.
    [/code]
    or you could do:
    [code]
    #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.
    [/code]
    We can use __attribute__ instead of #pragma, like this:
    [code]
    struct Packaging {
    char c;
    int i;
    } __attribute__((packed)) Packaging;
    [/code]
    It will have the same effect as pragma.
    And there are a lot of other uses for __attribute__.
  • 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.


    [link=http://www.hyphentechnologies.in/website-designing.php]Website Design Company[/link] | [link=http://www.hyphentechnologies.in/graphic-designing.php]Graphics Design Services[/link]
  • 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.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories