My code:
JavaScript
x
public function loadFFI()
{
FFI::load("C:phptestdummy.h");
}
dummy.h:
JavaScript
struct ffitest
{
char test1[16];
byte test2;
};
Error:
PHP Fatal error: Uncaught FFIParserException: Undefined C type “byte” at line 4
Why can I not use word
or byte
in this struct
in PHP FFI? char
, int
, and short
work as expected.
Advertisement
Answer
There is no such thing as a byte
data type in standard C. Since char
is already defined as a single byte, you should use that instead. If you want values 0-255 instead of -127 to 127, don’t forget to make it an unsigned char
.