|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2024-12-07 18:53 UTC] nielsdos@php.net
-Status: Open
+Status: Verified
-Package: Unknown/Other Function
+Package: FFI
[2024-12-07 18:53 UTC] nielsdos@php.net
[2024-12-07 19:02 UTC] nielsdos@php.net
[2024-12-09 21:29 UTC] git@php.net
[2024-12-09 21:29 UTC] git@php.net
-Status: Verified
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 18:00:01 2025 UTC |
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.)