Re: compile error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/18/2012 03:00 PM, ap wrote:
> 
> 
> I have the following #define in my code
> #define SWAP64(p) ( (*(unsigned _int64*)(p)) = _byteswap_uint64(*(unsigned _int64*)(p)))
> When I compile I get the error: expected primary-expression before 'unsigned', 
> when I use SWAP64
> 
> Does anybody have any idea?

Yes.  This is not legal C code: a cast expression is not an lvalue.

Do this:

#define SWAP64(P) \
    unsigned _int64 *tmp = (unsigned _int64 *)P; \
    *tmp = _byteswap_uint64(*tmp);

But be aware that you might have aliasing errors, so this code may
still not be legal.  I suspect you have some very old C code.

Andrew.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux