Box2d clang:在包含的文件中:“operator-”的类型冲突

问题描述 投票:0回答:1

我刚刚将 Box2D 库 (#include ) 添加到我的项目 (C++17) 中,并遇到了一些错误,如下所列。

**In file included from /Users/me/.conan2/p/b/box2dd2031ba5ab13f/p/include/box2d/box2d.h:7:
In file included from /Users/me/.conan2/p/b/box2dd2031ba5ab13f/p/include/box2d/collision.h:7:
/Users/me/.conan2/p/b/box2dd2031ba5ab13f/p/include/box2d/math_functions.h:614:15: error: conflicting types for 'operator-'
  614 | inline b2Vec2 operator-( b2Vec2 a, b2Vec2 b )
      |               ^
/Users/me/.conan2/p/b/box2dd2031ba5ab13f/p/include/box2d/math_functions.h:602:15: note: previous definition is here
  602 | inline b2Vec2 operator-( b2Vec2 a )
      |               ^
/Users/me/.conan2/p/b/box2dd2031ba5ab13f/p/include/box2d/math_functions.h:626:15: error: conflicting types for 'operator*'
  626 | inline b2Vec2 operator*( b2Vec2 a, float b )
      |               ^
/Users/me/.conan2/p/b/box2dd2031ba5ab13f/p/include/box2d/math_functions.h:620:15: note: previous definition is here
  620 | inline b2Vec2 operator*( float a, b2Vec2 b )
      |               ^
2 errors generated.
make[2]: *** [CMakeFiles/carimbo.dir/cmake_pch.hxx.pch] Error 1
make[1]: *** [CMakeFiles/carimbo.dir/all] Error 2
make: *** [all] Error 2**

有什么问题吗?

c++ c clang box2d
1个回答
0
投票

感谢 ChatGPT,问题是因为我将库包含在外部“C”部分,移到外部解决了问题。

© www.soinside.com 2019 - 2024. All rights reserved.