Bitfields?

  • From: Geoff Leyland <geoff_leyland@xxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 7 Apr 2014 20:53:16 +1200

Hi,

http://luajit.org/ext_ffi_semantics.html seems to suggest that LuaJIT supports 
bitfields in ffi cdefs.  However:

$ luajit21 -e 'require"ffi".cdef"struct test { long d:8; };"'
luajit21: (command line):1: invalid value near ':'
stack traceback:
        [C]: in function 'cdef'
        (command line):1: in main chunk
        [C]: at 0x0100000bb0

Since I’m a bit rusty on bitfields, I checked my bitfield syntax with:

$ echo "struct test { long d:8; };" | clang -Wall -Wextra -c -xc -

which seems to work.  Anyone either know more about LuaJIT’s bitfield support 
or able to point out my obvious mistake?

Thanks,
Geoff

Other related posts: