4

我正在尝试将 NVIDIA 的 PhysX 集成到我的 Linux 代码库中。在它的一些头文件中,它定义了以下枚举:

physxvisualdebuggersdk/PvdErrorCodes.h

struct PvdErrorType
{
  enum Enum
  {
    Success = 0,
    NetworkError,
    ArgumentError,
    InternalProblem
  };
};

physxprofilesdk/PxProfileCompileTimeEventFilter.h:

struct EventPriorities
{
  enum Enum
  {
    None,       // the filter setting to kill all events
    Coarse,
    Medium,
    Detail,
    Never       // the priority to set for an event if it should never fire.
  };
};

这会导致以下编译错误:

/usr/local/include/PhysX3/physxvisualdebuggersdk/PvdErrorCodes.h:36:4: error: expected identifier before numeric constant
    Success = 0,
    ^
/usr/local/include/PhysX3/physxvisualdebuggersdk/PvdErrorCodes.h:36:4: error: expected ‘}’ before numeric constant
/usr/local/include/PhysX3/physxvisualdebuggersdk/PvdErrorCodes.h:36:4: error: expected unqualified-id before numeric constant

/usr/local/include/PhysX3/physxprofilesdk/PxProfileCompileTimeEventFilter.h:46:4: error: expected identifier before numeric constant
    None,  // the filter setting to kill all events
    ^
/usr/local/include/PhysX3/physxprofilesdk/PxProfileCompileTimeEventFilter.h:46:4: error: expected ‘}’ before numeric constant
/usr/local/include/PhysX3/physxprofilesdk/PxProfileCompileTimeEventFilter.h:46:4: error: expected unqualified-id before numeric constant

我确定这是因为X11/Xh #defines 'None' 和 'Success'。我已经确认这是问题所在,如果我同时#undef 'None' 和 'Success',我不再有错误。然而,这显然不是一件可取的事情。

我的问题是:作为必须同时使用这两个标头的开发人员,我应该采取的正确做法是什么?我应该将其作为错误报告给 NVIDIA 并等待修复,还是我可以自己做一些事情来解决问题(#undef 除外)?

谢谢你的时间!

4

1 回答 1

1

最明智的做法是以这样的方式分离实现,即在您的项目中,您不会在同一源文件中包含两个冲突的标头。一个文件处理 X,一个文件处理 PhysX,然后您的应用程序将这两个实现联系在一起。

于 2014-12-30T17:36:26.830 回答