Skip to content

[raymath] Add extern "C" to raymath header for C++ #3978

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

Merged
merged 4 commits into from
May 12, 2024

Conversation

JeffM2501
Copy link
Contributor

This just adds a C extern to raymath if it's compiled as C++ so that C++ compilers and linters don't generate warnings about initializer lists.

@Peter0x44
Copy link
Contributor

This doesn't help for GCC. Same -Wmissing-field-initializers warnings get generated, turning off name mangling won't do anything for that.

@Peter0x44
Copy link
Contributor

What I said also applies to clang, it generates the same.

Unfortunately, I think this has no clean solution
the only one that really would solve this is having a macro like:

#ifdef __cplusplus
#define RAYMATH_STRUCT_ZERO {}
#else
#define RAYMATH_STRUCT_ZERO {0}
#endif

and using it in place of {0} throughout raymath.h. Unfortunately that's ugly and invasive, and also stops you from being able to directly copy individual functions out of raymath.h for your own modification

@raysan5 raysan5 changed the title [RAYMATH] Add extern "C" to raymath header for C++ [raymath] Add extern "C" to raymath header for C++ May 12, 2024
@raysan5 raysan5 merged commit 3d885ef into raysan5:master May 12, 2024
14 checks passed
@raysan5
Copy link
Owner

raysan5 commented May 12, 2024

@JeffM2501 wow! I missed that one! thanks for the update!

@JeffM2501
Copy link
Contributor Author

This PR needs to be reverted, it breaks debug builds in MinGW-W64 when raymath is included from a cpp file and links raylib static. As @Peter0x44 pointed out, it doesn't fix warnings, so it's not a big deal to revert. Please see PR #3985 for the revert.

@JeffM2501 JeffM2501 deleted the Raymath_extern_c branch June 25, 2024 23:02
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

Successfully merging this pull request may close these issues.

3 participants