Re: compile error

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

 



Andrew Haley <aph@xxxxxxxxxx> writes:

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

In the macro

  #define SWAP64(p) ( (*(unsigned _int64*)(p)) = _byteswap_uint64(*(unsigned _int64*)(p)))

the lvalue is (*(unsigned _int64*)(p)), which is not a cast expression.
I get the same error "expected primary-expression before 'unsigned'"
if I compile the expression as C++ (not C) and don't define _int64.
So, not defining _int64 is probably the cause of the error.  Also,
if _int64 is not defined, then _byteswap_uint64 is probably not
declared either.  I suggest:

  #include <stdint.h>
  typedef int64_t _int64;
  inline uint64_t _byteswap_uint64(uint64_t u) { return __builtin_bswap64(u); }

(By the way, GCC 3 had an extension "Generalized Lvalues",
but it was removed in SVN r76192, on 20 January 2004,
and would not have helped here in any case.)


[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