On the official LuaJIT website one can read the following:
The C parser complies to the C99 language standard plus the following extensions:
- The '\e' escape in character and string literals.
This should mean that LuaJIT C parser supports string literals!
Let's try:
ffi.cdef[[static const char * s = "foo";]]
ffi.cdef[[static const char s[] = "foo";]]
ffi.cdef[[static const char s[4] = "foo";]]
Unfortunately, none of the above works: the error invalid C type is raised on each ffi.cdef invocation.
Can you provide an example how to feed a string literal to the C parser integrated into LuaJIT?
P.S.
I should mention that I can successfully declare int and char variables the same way, but not strings.
ffi.cdef[[static const int k = 42;]]
print(ffi.C.k) --> 42