Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Paragma Pack() in vxWorks

535 views
Skip to first unread message

Krishna Kishore Reddy Sureddy

unread,
Jun 21, 2001, 11:35:58 PM6/21/01
to
Hi vxWorks Gurus,
What is sigificance of argument passed to #pragma pack() in "C" and
"vxWorks".
Thanks and Regards,
S.K.K.Reddy.

Dave Korn

unread,
Jun 22, 2001, 12:01:29 PM6/22/01
to
Krishna Kishore Reddy Sureddy wrote in message
<9gugoh$9f7$1...@overload.lbl.gov>...

>Hi vxWorks Gurus,
>What is sigificance of argument passed to #pragma pack() in "C" and
>"vxWorks".

Alas, the only documentation on these is buried deep in the instructions
for how to modify and retarget the compiler to a new cpu. Here they are: I
don't know whether or not the #pragma pack (pull/push) variants are
implemented or not.

----snip---
`HANDLE_SYSV_PRAGMA'
Define this macro (to a value of 1) if you want the System V style
pragmas `#pragma pack(<n>)' and `#pragma weak <name> [=<value>]'
to be supported by gcc.

The pack pragma specifies the maximum alignment (in bytes) of
fields within a structure, in much the same way as the
`__aligned__' and `__packed__' `__attribute__'s do. A pack value
of zero resets the behaviour to the default.

The weak pragma only works if `SUPPORTS_WEAK' and
`ASM_WEAKEN_LABEL' are defined. If enabled it allows the creation
of specifically named weak labels, optionally with a value.

`HANDLE_PRAGMA_PACK_PUSH_POP'
Define this macro (to a value of 1) if you want to support the
Win32 style pragmas `#pragma pack(push,<n>)' and `#pragma
pack(pop)'. The pack(push,<n>) pragma specifies the maximum
alignment (in bytes) of fields within a structure, in much the
same way as the `__aligned__' and `__packed__' `__attribute__'s
do. A pack value of zero resets the behaviour to the default.
Successive invocations of this pragma cause the previous values to
be stacked, so that invocations of `#pragma pack(pop)' will return
to the previous value.
----snip---


DaveK
--
They laughed at Galileo. They laughed at Copernicus. They laughed at
Columbus. But remember, they also laughed at Bozo the Clown.


Melvin Gardipee >

unread,
Jun 22, 2001, 12:55:20 PM6/22/01
to
Hi Krishna,

The GNU ToolKit Users Guide only reference to #pragma gives
reasons for not using them ending with the quote "It is basically a
mistake to use #pragma for anything". Use of #pragma in the 1.34
version of GNU C compiler would cause the cause the compiler to stop
and launch a computer game. It was their idea of implementing the
ANSI standard 'arbitrary implementation-defined effect'.
I would avoid using #pragma with GNU compilers. If you are
communicating with a VxWorks based system from a different OS,
#pragma pack your structures to match the VxWorks layout. For Win32
to VxWorks communication, you can #pragma pack on the Win32 side
in a common header file using something like this:

#ifdef WIN32
#pragma pack( push, some_unique_name )
#pragma pack(8)
#endif

<COMMON TYPEDEF'S HERE>

#ifdef WIN32
#pragma pack( pop, some_unique_name )
#endif

The above example works for PPC architectures.


Regards,
Melvin Gardipee

0 new messages