minetest / irrlicht

Minetest's fork of Irrlicht
Other
115 stars 87 forks source link

Ensure that std::abs is used and not integer abs #293

Closed paradust7 closed 4 months ago

paradust7 commented 4 months ago

I have C++20 enabled in xr build for MSVC, and abs triggers an error here because it is trying to choose between non-std integer versions of abs:

irrMath.h(200,10): error C2668: 'abs': ambiguous call to overloaded function 

  C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\stdlib.h(368,22):
  could be '__int64 abs(const __int64) noexcept'
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\stdlib.h(363,17):
  or       'long abs(const long) noexcept'
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_math.h(470,38):
  or       'int abs(int)'

This fixes this error by ensuring std::abs is always used.