0
votes

I have a project (VS2012) that uses the 0.5.0.1 SDK. The SDK includes a System class under the OVR namespace (OVR::System). In a class that I wrote, I'm using ::System. This works and isn't what's giving me the problem. When I compile, I get error C2872: 'System': ambiguous symbol and the problematic files are typeinfo, xlocale, and xiosbase in C:....\Microsoft Visual Studio 12.0\VC\include. The error says that "System" could either be "System" or OVR::System. Is there a way around this? How can I get typeinfo, xlocale and xiosbase to use ::System and not OVR::System without changing the contents of the files (which I don't want to do)?

1
Do not use using namespace OVR;Vlad from Moscow
Welcome to Stack Overflow! Please provide an SSCCE.NathanOliver
It's not clear from your question: Are you getting compile errors in your CPP file, or are you getting errors in the header files when you include them from your CPP?David Yaw

1 Answers

1
votes

A using namespace OVR; directive shouldn't be a problem, unless you wrote it above your #include directives.

References to library header files should always come before your own code, precisely so that this sort of thing doesn't happen. The one exception is when library documentation tells you to define a particular macro to control library behavior, in that case the library is designed to work with your definition.

Bad:

using namespace OVR;
#include <typeinfo>
#include <locale>

Good:

#include <typeinfo>
#include <locale>
using namespace OVR;