What is __attribute__ ? 
Author Message
 What is __attribute__ ?

Hi,

Can somone help me for understanding following?

#define PACKED(item) item __attribute__ ((packed))

The usage may like:

struct xxx {
    unsigned PACKED(type:    4);  
    ....

Quote:
}

or
struct yyy{
   union foo PACKED(bar);

Quote:
}

Thanks,
ios


Sun, 18 Apr 2004 08:14:12 GMT  
 What is __attribute__ ?

    ios> Hi,
    ios> Can somone help me for understanding following?

    ios> #define PACKED(item) item __attribute__ ((packed))

It's a gcc extension.

<OT> It tells the compiler not to put padding in between struct
elements </OT>

You should probably ask in the gnu.gcc newsgroup.

Cheers,
Kevin

--
He that breaks a thing to find out what it is has left the path of
wisdom                                         -- Gandalf the Grey



Sun, 18 Apr 2004 08:23:28 GMT  
 What is __attribute__ ?

Quote:
>Hi,

>Can somone help me for understanding following?

>#define PACKED(item) item __attribute__ ((packed))

__attribute__ is some feature of your compiler. You need to read the
documentation for that.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>



Sun, 18 Apr 2004 08:33:12 GMT  
 What is __attribute__ ?

Quote:


>     ios> Hi,
>     ios> Can somone help me for understanding following?

>     ios> #define PACKED(item) item __attribute__ ((packed))

> It's a gcc extension.

> <OT> It tells the compiler not to put padding in between struct
> elements </OT>

> You should probably ask in the gnu.gcc newsgroup.

Thanks.
Where is it? I can not find it in the google

So what is ((packed)) mean?

Quote:

> Cheers,
> Kevin



Mon, 19 Apr 2004 16:25:11 GMT  
 What is __attribute__ ?
On 1 Nov 2001 00:25:11 -0800, ios said:

Quote:
>Thanks.
>Where is it? I can not find it in the google

comp.gnu.gcc

Quote:
>So what is ((packed)) mean?

Try the following...

#include <stdio.h>
#include <stddef.h>

struct a
{
    char c;
    int j;

Quote:
} s_a;

struct b
{
    char c;
    int j;

Quote:
} __attribute__((packed));

struct b s_b;

int main(void)
{
    printf("\nOffset of s_a.c: %d\nOffset "
    "of s_a.j: %d\n", &s_a.c, &s_a.j);
    printf("\nOffset of s_b.c: %d\nOffset "
    "of s_b.j: %d\n", &s_b.c, &s_b.j);

    return 0;

Quote:
}

>> Cheers,
>> Kevin

--

Palamon Technologies Ltd.  Phone +353-1-634-5059      


Mon, 19 Apr 2004 20:03:14 GMT  
 What is __attribute__ ?

Quote:

>> You should probably ask in the gnu.gcc newsgroup.

The newsgroup he needs is gnu.gcc.help.

Quote:
>Thanks.
>Where is it? I can not find it in the google

Learn how to use google, because it's right there.  You have to click on
the "Browse complete list of groups..." link.

Dan
--
Dan Pop
CERN, IT Division

Mail:  CERN - IT, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland



Mon, 19 Apr 2004 23:55:07 GMT  
 What is __attribute__ ?

Quote:
>On 1 Nov 2001 00:25:11 -0800, ios said:
>>Thanks.
>>Where is it? I can not find it in the google

>comp.gnu.gcc

Please don't post bogus newsgroup names!

Dan
--
Dan Pop
CERN, IT Division

Mail:  CERN - IT, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland



Mon, 19 Apr 2004 23:55:51 GMT  
 What is __attribute__ ?
Hi David,

Your example really help me.

Thanks,
ios

Quote:

> On 1 Nov 2001 00:25:11 -0800, ios said:
> >Thanks.
> >Where is it? I can not find it in the google

> comp.gnu.gcc

> >So what is ((packed)) mean?

> Try the following...

> #include <stdio.h>
> #include <stddef.h>

> struct a
> {
>     char c;
>     int j;
> } s_a;

> struct b
> {
>     char c;
>     int j;
> } __attribute__((packed));

> struct b s_b;

> int main(void)
> {
>     printf("\nOffset of s_a.c: %d\nOffset "
>     "of s_a.j: %d\n", &s_a.c, &s_a.j);
>     printf("\nOffset of s_b.c: %d\nOffset "
>     "of s_b.j: %d\n", &s_b.c, &s_b.j);

>     return 0;
> }

> >> Cheers,
> >> Kevin



Wed, 21 Apr 2004 05:23:38 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Attributed and non-attributed code performance

2. I am new to programming and am lost

3. ATL, importlib attribute, library attribute, ADO

4. Retriving attribute from custom attribute collection

5. Creating custom attribute in assembly and accessing attribute from different project

6. how good am I? Am I Good Enough????

7. ATL COM Exe with attributes, non attributed client question...

8. Determine where I am running

9. System.Threading.Timer , am I doing this correctly ?

10. OneWay() attribute

11. Am i connected?

12. read-only attribute

 

 
Powered by phpBB® Forum Software