Add support for C++20 modules#360
Add support for C++20 modules#360RobLoach merged 2 commits intoRobLoach:masterfrom mikomikotaishi:master
Conversation
|
@RobLoach Hi, are there any concerns regarding this PR before it could be merged? |
|
Also, I have a question about the library. Is there a particular reason you chose to continue use PascalCase for the methods/functions, rather than just camelCase? I know that in the original Raylib library the functions use PascalCase names, but besides that I feel like it is more difficult to distinguish function and class names if both are PascalCase. If that makes sense, would you considering allowing a build option using a preprocessor macro to toggle whether methods are PascalCase or camelCase? |
|
Thanks for pushing this forwards. Just hadn't had a look.
While I understand the C++ convention is usually camelCase, keeping them the same as raylib has a few benefits...
A preprocessor would be cool, but I'd fear it may result in a lot of maintenace issues. Could we have them be aliases or something so that the code could work in either case? |
|
Ah, sorry for my impatience. As far as I'm aware there is no way to alias function names with the keyword // example of Color::ToInt()
#ifndef RAYLIBCPP_CAMEL_CASE
[[nodiscard]] int ToInt() const
#else
[[nodiscard]] int toInt() const
#endif
{ return ::ColorToInt(*this); }etc. Now I understand that won't be the most elegant thing in the world, and would probably make the code look a lot harder to read, but it's the only thing I can think of. That being said we could rename all the methods by doing something like #ifdef RAYLIBCPP_CAMEL_CASE
// ...
#define TO_INT toInt
// ...
#define TO_INT ToInt
#else
#endifAlso, getters and setters could also be affected by the presence of that macro if we altered the |
|
I think keeping inline with the original raylib conventions may be best for the case. While changing it will make it feel more like C++, changing it will deviate from raylib, and break existing usage. |
This pull request adds support for C++20 modules, by enabling the macro
BUILD_RAYLIB_CPP_MODULESat build time. It gives access to the moduleraylib, which is imported by writingimport raylib;.