What is the exact way to pack structures (no extra spaces) in QNX 6? I’ve
tried to find help on the #pragma pack command in the help files but there
is nothing.
Thanks,
Jim
P.S. The docs for gcc/qcc are pretty weak
What is the exact way to pack structures (no extra spaces) in QNX 6? I’ve
tried to find help on the #pragma pack command in the help files but there
is nothing.
Thanks,
Jim
P.S. The docs for gcc/qcc are pretty weak
Jim Lambert <jlambert@futurex.com> wrote:
: What is the exact way to pack structures (no extra spaces) in QNX 6? I’ve
: tried to find help on the #pragma pack command in the help files but there
: is nothing.
: Thanks,
From the gcc info docs:
The keyword __attribute__' allows you to specify special attributes of variables or structure fields. This keyword is followed by an attribute specification inside double parentheses. Eight attributes are currently defined for variables:
aligned’, mode',
nocommon’,
packed',
section’, transparent_union',
unused’, and `weak’. Other
attributes are available for functions (*note Function Attributes: and
for types (*note Type Attributes::).
…
packed' The
packed’ attribute specifies that a variable or structure field
should have the smallest possible alignment–one byte for a
variable, and one bit for a field, unless you specify a larger
value with the `aligned’ attribute.
Here is a structure in which the field x' is packed, so that it immediately follows
a’:
struct foo
{
char a;
int x[2] attribute ((packed));
};
This is in the QNX docs? I searched on packed and attribute and it did
not come up. Thanks for the info, it works.
Where are these gcc info docs? I’d like to get a copy.
Thanks,
Jim
“Alain Magloire” <alain@qnx.com> wrote in message
news:a0i3ag$j10$2@nntp.qnx.com…
Jim Lambert <> jlambert@futurex.com> > wrote:
: What is the exact way to pack structures (no extra spaces) in QNX 6?
I’ve
: tried to find help on the #pragma pack command in the help files but
there
: is nothing.: Thanks,
From the gcc info docs:
Specifying Attributes of Variables
The keyword
__attribute__' allows you to specify special attributes of variables or structure fields. This keyword is followed by an attribute specification inside double parentheses. Eight attributes are currently defined for variables:
aligned’,mode',
nocommon’,
packed',
section’,transparent_union',
unused’, and `weak’. Other
attributes are available for functions (*note Function Attributes: and
for types (*note Type Attributes::).…
packed' The
packed’ attribute specifies that a variable or structure field
should have the smallest possible alignment–one byte for a
variable, and one bit for a field, unless you specify a larger
value with the `aligned’ attribute.Here is a structure in which the field
x' is packed, so that it immediately follows
a’:struct foo
{
char a;
int x[2] attribute ((packed));
};
Jim Lambert <jlambert@futurex.com> wrote:
: This is in the QNX docs? I searched on packed and attribute and it did
: not come up. Thanks for the info, it works.
: Where are these gcc info docs? I’d like to get a copy.
http://gcc.gnu.org/ (search for manuals)
Or in the src distribution, I believe we use 2.95.2.
You can also order them from the FSF (nicely covered etc …)
http://www.gnu.org
On 28 Dec 2001 21:30:44 GMT, Alain Magloire <alain@qnx.com> wrote:
(…)
ako
Jim Lambert <jlambert@futurex.com> wrote:
What is the exact way to pack structures (no extra spaces) in QNX 6? I’ve
tried to find help on the #pragma pack command in the help files but there
is nothing.
Warning: unaligned access to data-types can result in pogram failure
(SIGBUS error) on non-x86 CPU platforms.
QNX Training Services
I do not answer technical questions by email.