fredakilla / Urhox

Urho3D extension library
22 stars 12 forks source link

Unable to compile: "error: redefinition of `unsigned int Urho3D::ClosestPowerOfTwo(unsigned int)`" #1

Open JayFoxRox opened 3 years ago

JayFoxRox commented 3 years ago
$ gcc --version
gcc (GCC) 10.2.0
[ 14%] Building CXX object Sources/Urhox/CMakeFiles/urhoxcore.dir/SystemUI/SystemUI.cpp.o
spkgen/3rdparty/Urhox/Sources/Urhox/SystemUI/SystemUI.cpp:45:17: error: redefinition of ‘unsigned int Urho3D::ClosestPowerOfTwo(unsigned int)’
   45 | inline unsigned ClosestPowerOfTwo(unsigned value)
      |                 ^~~~~~~~~~~~~~~~~
In file included from spkgen/3rdparty/Urho3D/build/include/Urho3D/Input/../Core/../Core/../Math/../Math/../Math/../Math/Vector2.h:26,
                 from spkgen/3rdparty/Urho3D/build/include/Urho3D/Input/../Core/../Core/../Math/../Math/../Math/Vector3.h:25,
                 from spkgen/3rdparty/Urho3D/build/include/Urho3D/Input/../Core/../Core/../Math/../Math/Vector4.h:25,
                 from spkgen/3rdparty/Urho3D/build/include/Urho3D/Input/../Core/../Core/../Math/Color.h:25,
                 from spkgen/3rdparty/Urho3D/build/include/Urho3D/Input/../Core/../Core/Variant.h:29,
                 from spkgen/3rdparty/Urho3D/build/include/Urho3D/Input/../Core/Object.h:27,
                 from spkgen/3rdparty/Urho3D/build/include/Urho3D/Input/InputEvents.h:25,
                 from spkgen/3rdparty/Urhox/Sources/Urhox/SystemUI/SystemUI.cpp:22:
spkgen/3rdparty/Urho3D/build/include/Urho3D/Input/../Core/../Core/../Math/../Math/../Math/../Math/../Math/MathDefs.h:280:17: note: ‘unsigned int Urho3D::ClosestPowerOfTwo(unsigned int)’ previously defined here
  280 | inline unsigned ClosestPowerOfTwo(unsigned value)
      |                 ^~~~~~~~~~~~~~~~~

I assume this stems from the handling of inline which is not very well defined in C / C++.


(Edit: Looks like it's enough to remove this function from SystemUI.cpp; seems to work fine then)

DDFighting commented 3 years ago

systemUiScalePixelPerfect = { (float)ClosestPowerOfTwo((unsigned)scale.x), (float)ClosestPowerOfTwo((unsigned)scale.y), (float)ClosestPowerOfTwo((unsigned)scale.z_) };