Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFI and PHP #202

Open
devnix opened this issue Jan 24, 2021 · 1 comment
Open

FFI and PHP #202

devnix opened this issue Jan 24, 2021 · 1 comment

Comments

@devnix
Copy link

devnix commented Jan 24, 2021

Hi! I'm trying to call Chipmunk's FFI from PHP.

I think I'm almost there, but the header files have some issues when parsed by PHP's FFI. Right now I'm running cpp -P -D "__attribute__(ARGS)=" ~/tmp/Chipmunk2D/include/chipmunk/chipmunk.h -o include/chipmunk.h to get an already pre-processed header file, and I'm removing the #include <stdlib.h>. #include <math.h> lines for now.

My actual problem is a FFI\ParserException: ';' expected, got '{' at line 4 error when trying to load the library.

static inline cpFloat cpfmax(cpFloat a, cpFloat b)
{                                                        // This is line 4
 return (a > b) ? a : b; 
}

This is my first experience implementing a FFI. There's something I would need to consider? Should I curate my own .h file and write manually there the definitions as I'm needing it?

Maybe could be worth to investigate if a tool like SWIG would help making the library more friendly to make bindings?

@devnix
Copy link
Author

devnix commented Jan 25, 2021

Well, I guess I made some progress manually removing the implementation of those inline functions (for example, turning it like static inline cpFloat cpfmax(cpFloat a, cpFloat b)).

But it seems like those functions are not implemented in the dynamic library, so I can't access to them!

FFI\Exception: Attempt to call undefined C function 'cpv'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant