tinyexpr
tinyexpr copied to clipboard
C11 and C++20
-
Replaces unsafe usages of const void* with appropriate pointer types for data and functions, making the code maximum portable, safe, and easier to maintain. Detail: Some compilers does not allow casting between data and function pointers, even void* (pointers may have different sizes).
-
Library now compilable both in c11 and c++20. Useful if you need to customize the code with a c++ allocator or use it in projects where c++ source code is required. Broadens usability of the library.
Note that it is only unnamed structs that requires C11, but unnamed structs are supported on every C99 compiler that I know of (including MSVC which isn't even C99 compliant).
-
For c++, the PR forces the correct overloaded math functions to be picked during function pointer assignments and comparisons, e.g. like pow and fmod.
-
Simplifies casting code in te_eval() by adding a few macros, can extend number of function parameters cleanly.
Great, I'm looking forward to a C++11 / C++20 compatible tinyexpr! This could make the compilation environment a little easier when integrating tinexpr in a C++11 project (ie no need to check on multiple platforms and compilers that this one file will be compiled as c99 vs the other ones as c++11).