2014-12-30 9 views
3

NVIDIA의 PhysX를 내 Linux 코드베이스에 통합하려고합니다. 헤더 파일의 일부에서, 다음 열거 정의#define 매크로와 동일한 이름을 사용하는 enum에 의한 충돌

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/X.h # 정의 '없음'과 '성공'모두. 나는 이것이 'None'과 'Success'둘 다 #undef하면 더 이상 오류가없는 것으로서 이것이 문제라는 것을 확인했습니다. 그러나 이것은 분명히 바람직한 일이 아닙니다.

내 질문은 :이 두 헤더를 모두 사용해야하는 개발자로서 올바른 조치 과정은 무엇입니까? NVIDIA에 버그로보고하고 수정 사항을 기다려야합니까? 아니면 (#undef 외에도) 문제를 해결할 수있는 방법이 있습니까?

시간 내 주셔서 감사합니다.

+0

#define names는 모두 대문자 여야합니다. 이렇게하면 일반적으로 이러한 문제가 해결됩니다. – NathanOliver

+0

@NathanOliver 불행히도 이러한 매크로는 시스템 헤더 파일에 정의되어 있으며 편집 할 수 없으며 편집 할 수도 없습니다. –

+0

'# undef' 트릭을 사용하거나 열거 형 값의 이름을 바꾸거나 X11 헤더 파일을 열거 형이 사용 된 파일과 같은 파일에 포함시키지 않을 수 없습니다. –

답변

1

가장 확실한 방법은 프로젝트 내에서 동일한 소스 파일에 충돌 헤더 두 개가 모두 포함되지 않도록 구현을 분리하는 것입니다. 하나의 파일은 X를 다루고 하나는 PhysX를 다루고, 두 개의 파일은 두 가지 구현을 함께 묶습니다.