This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: compile error


Andrew Haley <aph@redhat.com> 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]