compile error

Kalle Olavi Niemitalo
Wed Jul 18 15:47:00 GMT 2012

Andrew Haley <> 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.)

More information about the Gcc-help mailing list