Bug #79075 [Com]: FFI header parser chokes on comments
| From: | gpagac at hotmail dot com | Date: | Thu, 23 Sep 2021 09:14:01 +0000 |
| Subject: | Bug #79075 [Com]: FFI header parser chokes on comments | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-236768@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79075&edit=1
ID: 79075
Comment by: gpagac at hotmail dot com
Reported by: larry at garfieldtech dot com
Summary: FFI header parser chokes on comments
Status: Open
Type: Bug
Package: Unknown/Other Function
Operating System: Ubuntu 19.10
PHP Version: 7.4.1
Block user comment: N
Private report: N
New Comment:
Un bouchon de tonalité, un microphone ou des haut-parleurs sont nécessaires. https://cookie-clicker2.co/
Previous Comments:
------------------------------------------------------------------------
[2020-01-07 21:45:34] larry at garfieldtech dot com
Description:
------------
(I couldn't find an FFI section in the packages affected section; feel free to relocate this
ticket to the right location.)
When using FFI, If the .h file contains a comment that comes before a #define then the FFI::load()
will fail with a Warning: cannot resolve C function.
This does not seem to happen if the same .h file is used in FFI::cdef().
That is, the following header file works fine:
```
#define FFI_SCOPE "POINTS"
#define FFI_LIB "./points.so"
struct point {
int x;
int y;
};
// Foo
double distance(struct point first, struct point second);
```
But this version fails in FFI::load(), and works in FFI::cdef():
```
#define FFI_SCOPE "POINTS"
// Foo
#define FFI_LIB "./points.so"
struct point {
int x;
int y;
};
double distance(struct point first, struct point second);
```
I have verified the same behavior regardless of whether // or /* */ comments are used.
Test script:
---------------
See: https://github.com/Crell/ffi-test/tree/476610f469aff116f41131948e58b0e27f9b9a57
That commit has a directory "points" with sample code. (It's fixed in more recent
comments.) To demonstrate, change into that directory and run "make inline". That will
work. Then run "make preload", which uses the preload-with-load() approach. It will
fail. Then modify the points.h file to remove the comment between the #define statements. It will
now work.
(At least that's what I experienced.)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79075&edit=1