Re: struct __attribute((packed));

2005-04-15 Thread E. Weddington
Ralf Corsepius wrote: On Fri, 2005-04-15 at 10:39 -0600, E. Weddington wrote: What?! That whole section in the docs talks about attributes on types. If it doesn't work as described, then the docs need some serious rework. From what I see, the example for packed types doesn't even compile:

Re: struct __attribute((packed));

2005-04-15 Thread Ralf Corsepius
On Fri, 2005-04-15 at 10:39 -0600, E. Weddington wrote: > What?! That whole section in the docs talks about attributes on types. > If it doesn't work as described, then the docs need some serious rework. >From what I see, the example for packed types doesn't even compile: (Direct cut'n'paste fr

Re: struct __attribute((packed));

2005-04-15 Thread E. Weddington
Andrew Haley wrote: gcc.info: The `aligned' attribute can only increase the alignment; but you can decrease it by specifying `packed' as well. See below. Thanks for the correction. Bleah. :-P I'll go back into lurk mode now Eric

Re: struct __attribute((packed));

2005-04-15 Thread Andrew Haley
E. Weddington writes: > Paul Koning wrote: > > >>"E" == E Weddington <[EMAIL PROTECTED]> writes: > >> > >> > > > > > > E> typedef int packed_int __attribute__ ((aligned (1))); > > > >I'd rather the compiler got the work than the docs. > > > >Maybe it's better i

Re: struct __attribute((packed));

2005-04-15 Thread E. Weddington
Paul Koning wrote: "E" == E Weddington <[EMAIL PROTECTED]> writes: E> typedef int packed_int __attribute__ ((aligned (1))); I'd rather the compiler got the work than the docs. Maybe it's better in newer versions; I don't have anything newer than 3.4.1 built right now. Test program: ty

Re: struct __attribute((packed));

2005-04-15 Thread Dale Johannesen
On Apr 15, 2005, at 8:27 AM, E. Weddington wrote: Ralf Corsepius wrote: Hi, I just tripped over this snipped below in a piece of code, I didn't write and which I don't understand: ... struct somestruct { struct entrystruct *e1 __attribute__ ((packed)); struct entrystruct *e2 __attribute__ ((packe

RE: struct __attribute((packed));

2005-04-15 Thread Joseph S. Myers
On Fri, 15 Apr 2005, Dave Korn wrote: > I've often wished that __attribute__s would behave like CV-quals: The syntax of attributes is documented in the Attribute Syntax section of the manual. http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html Nested in pointer sequences they do act like

Re: struct __attribute((packed));

2005-04-15 Thread Paul Koning
> "E" == E Weddington <[EMAIL PROTECTED]> writes: E> Paul Koning wrote: According to the docs here: E> >> E> what about doing something like this?: >> E> typedef int packed_int __attribute__ ((aligned (1)

Re: struct __attribute((packed));

2005-04-15 Thread E. Weddington
Paul Koning wrote: E> According to the docs here: E> E> what about doing something like this?: E> typedef int packed_int E> __attribute__ ((aligned (1))); E> packed_int *ppi; That would make sense, but it has never

Re: struct __attribute((packed));

2005-04-15 Thread Paul Koning
> "E" == E Weddington <[EMAIL PROTECTED]> writes: E> Paul Koning wrote: >> It sure would be useful, though, if there were a construct that >> does mean "pointer to packed T". In particular, I've often needed >> "pointer to packed int" and found no way to produce that. I ended >> up crea

Re: struct __attribute((packed));

2005-04-15 Thread E. Weddington
Dave Korn wrote: I've often wished that __attribute__s would behave like CV-quals: char * const ptr; == const pointer to char struct entrystruct * __attribute__ ((packed)) entry; == packed pointer to struct char const * ptr; == pointer to const char struct entrystruct __attribute__ ((packed))

RE: struct __attribute((packed));

2005-04-15 Thread Dave Korn
Original Message >From: E. Weddington >Sent: 15 April 2005 17:10 > Ralf Corsepius wrote: >> struct entrystruct * entry __attribute__ ((packed)); >> >> is interpreted as "packed pointer to struct" >> not as "pointer to packed struct", >> >> > I would interpret it that way too: packed po

Re: struct __attribute((packed));

2005-04-15 Thread E. Weddington
Paul Koning wrote: It sure would be useful, though, if there were a construct that does mean "pointer to packed T". In particular, I've often needed "pointer to packed int" and found no way to produce that. I ended up creating a one-member struct with a packed int inside, which is a syntactic nig

Re: struct __attribute((packed));

2005-04-15 Thread E. Weddington
Ralf Corsepius wrote: On Fri, 2005-04-15 at 09:27 -0600, E. Weddington wrote: It seems that GCC will interpret the above as e1 and e2 is packed within the struct somestruct so that e2 "immediately follows e1" (according to the manual). The packed attribute in this case does not refer to what e

Re: struct __attribute((packed));

2005-04-15 Thread Paul Koning
> "Ralf" == Ralf Corsepius <[EMAIL PROTECTED]> writes: Ralf> struct entrystruct * entry __attribute__ ((packed)); Ralf> is interpreted as "packed pointer to struct" not as "pointer to Ralf> packed struct", i.e. this construct is not meaningful. Yes it's meaningful, it may not be what you

Re: struct __attribute((packed));

2005-04-15 Thread Ralf Corsepius
On Fri, 2005-04-15 at 09:27 -0600, E. Weddington wrote: > Ralf Corsepius wrote: > > >Hi, > > > >I just tripped over this snipped below in a piece of code, I didn't > >write and which I don't understand: > > > >... > >struct somestruct { > > struct entrystruct *e1 __attribute__ ((packed)); > > st

Re: struct __attribute((packed));

2005-04-15 Thread E. Weddington
Ralf Corsepius wrote: Hi, I just tripped over this snipped below in a piece of code, I didn't write and which I don't understand: ... struct somestruct { struct entrystruct *e1 __attribute__ ((packed)); struct entrystruct *e2 __attribute__ ((packed)); }; ... Is this meaningful? I guess the author