Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

Type cast to byte aligned variable in GCC

Type cast to byte aligned variable in GCC

2006-02-19 by weartronics

Dear lpc2000,

I am trying to port some Keil example code (LPC2148 USBHID) to the GCC
compiler. Keil use the __packed keyword to specify byte alignment for
variables (see
http://www.keilsoftware.com/support/man/docs/ca/ca_le_packed.htm) but
this is not supported by GCC. I know GCC provides an "__attribute__
((__packed__))" which can be used in variable declarations, but how
can I type cast to a byte aligned variable type!? My problem line is
below...

*((__packed WORD *)EP0Buf) = (USB_EndPointHalt & m) ? 1 : 0;

Thanks!

Nic

Re: Type cast to byte aligned variable in GCC

2006-02-20 by Thiadmer Riemersma (ITB CompuPhase)

I built macros to handle such cases. This is more portable. I use GCC,
but I actually don't know whether the syntax that you are proposing is
supported.

Re: [lpc2000] Re: Type cast to byte aligned variable in GCC

2006-02-20 by nic@weartronics.com

Hi Thiadmer,

Thanks for your reply, I think you may be correct the type cast to byte 
aligned variable is not possible using GCC.

Can you show me an example of your macros, so I can try to rewrite the 
code to use the macros instead?

Kind regards,

Nic

Thiadmer Riemersma (ITB CompuPhase) wrote:
Show quoted textHide quoted text
>I built macros to handle such cases. This is more portable. I use GCC,
>but I actually don't know whether the syntax that you are proposing is
>supported.
>
>
>
>
>
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>
>
>  
>

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.