I am trying to integrate NVIDIA's PhysX into my Linux codebase. In some of its header files, it defines the following enums:
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.
};
};
Which results in the following compile errors:
/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
and
/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
I have determined that this is because X11/X.h #defines both 'None' and 'Success'. I have confirmed that this is the issue as, if I #undef both 'None' and 'Success', I no longer have the errors. However, this obviously isn't a desirable thing to do.
My question is: As a developer who has to use both these headers, what is the correct course of action for me to take? Should I report it to NVIDIA as a bug and wait for a fix or is there something that I can do myself to resolve the issue (besides #undef)?
Thanks for your time!
#undef
trick, or to rename your enumerations values, or to not include the X11 header files in the same files where your enumerations are used. – Po#undef
them and then immediately re-#define
them after theenum
is declared. This is ugly, but not sure what else you can do. – Polaroidenum
afterwards though. – Traitorousenum
is used, which makes the solution even uglier... – Polaroid