Why is the result of const char * a string and char * an object „byte-array“? A simple example: returns Removing const from the definition returns: Background A function of a dynamically linked external C library returns binary data which include NULL-bytes. When const is in the definition of the header file the resulting string is not complete = shortened
Tag: php-ffi
Why i cannot use word, byte on struct in PHP FFI? But char, int, short works?
My code: dummy.h: 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. Answer There is no such thing as a byte data type in standard C. Since char is already defined as a single byte,
PHP FFI – return array rom Rust function back to PHP
I need to return few values from rust function. Tried to declare function which returns an array But got an error: PHP Fatal error: Uncaught FFIParserException: function returning array is not allowed at line 1 in /array.php:3 It seems PHP FFI can’t work with arrays directly. So I found another solution. I created C-array from PHP, then passed pointer to
php-ffi: Assign char* of a struct
I’m trying to set the value of a char* of a struct. This is a basic example: I’m getting an exception: FFIException: Incompatible types when assigning to type ‘char*’ from PHP ‘string’ My question is: How to set the char *name of a struct? My dirty way was to make an array of chars, str_split the string and set the
Problem loading a library with FFI in PHP 7.4
I’m having trouble using a third party .so library in PHP with the new FFI. When I run this little piece of code: PHP outputs me this error: Is this a problem with the library itself, my PHP configuration or something else? It’s confusing to me, because I can use normally this same library with this C++ code: I’m aware