-
Notifications
You must be signed in to change notification settings - Fork 47
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
C friendly header #40
Comments
I tried this myself and identified these issues: JoyShockLibrary.h:114:9: error: unknown type name ‘bool’
114 | bool t0Down;
| ^~~~ Access to the JoyShockLibrary.h:122:8: error: expected identifier or ‘(’ before string constant
122 | extern "C" JOY_SHOCK_API int JslConnectDevices();
| ^~~ extern "C" is not valid under C, it is C++ only These two are easy to fix with some #define 152 extern "C" JOY_SHOCK_API TOUCH_STATE JslGetTouchState(int deviceId, bool previous = false);
153 extern "C" JOY_SHOCK_API bool JslGetTouchpadDimension(int deviceId, int &sizeX, int &sizeY); The last problem that isn't so quick and uncontroversial to correct is that the API uses references and default arguments. It would be a breaking change to fix that, which would surely annoy existing users. Perhaps a reason supporting creating a separate header with a C api for the library, though it would be questionable code duplication. So it leaves the question: The API is very close to being C compatible, but not quite... I'm happy to submit a PR implementing whichever approach the maintainer(s) deem appropriate. |
I'm currently writing a Max/MSP library (external) using JoyShockLibrary in C. Current header file is not so C friendly. Seperating headers for C and C++ or modifying current file could work. What you think?
The text was updated successfully, but these errors were encountered: