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が'None' と 'Success' の両方を #define するためであると判断しました。「None」と「Success」の両方を #undef すると、エラーが発生しなくなるため、これが問題であることを確認しました。ただし、これは明らかに望ましいことではありません。

私の質問は次のとおりです。これらのヘッダーを両方とも使用しなければならない開発者として、私が取るべき正しい行動方針は何ですか? バグとして NVIDIA に報告して修正を待つべきですか、それとも問題を解決するために自分でできることはありますか (#undef 以外に)?

御時間ありがとうございます!

4

1 に答える 1

1

最も健全な方法は、プロジェクト内で同じソース ファイルに競合するヘッダーの両方を含めないように実装を分離することです。1 つのファイルで X を処理し、もう 1 つのファイルで PhysX を処理し、アプリケーションで 2 つの実装を結び付けます。

于 2014-12-30T17:36:26.830 に答える