tinyexpr icon indicating copy to clipboard operation
tinyexpr copied to clipboard

C11 and C++20

Open tylov opened this issue 4 years ago • 1 comments

  • 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.

tylov avatar Nov 02 '20 16:11 tylov

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).

bavay avatar Oct 04 '21 08:10 bavay