Fix C++17 MSVC compilation error

With C++17, Windows headers must not be included after `using namespace std;`.

Windows headers define a `byte` type internally and `using namespace std`
causes it to conflict with `std::byte`:

    error C2872: 'byte': ambiguous symbol

MSVC thread: https://developercommunity.visualstudio.com/t/error-c2872-byte-ambiguous-symbol/93889
This commit is contained in:
Gleb Mazovetskiy 2021-03-16 21:46:50 +00:00 committed by Robert Osfield
parent 8a15f23c15
commit 9fb010fadd
3 changed files with 3 additions and 5 deletions

View File

@ -22,9 +22,6 @@
#include <algorithm> #include <algorithm>
#include <string.h> #include <string.h>
using namespace osg;
using namespace std;
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
#include<windows.h> #include<windows.h>
extern "C" { OSG_EXPORT DWORD NvOptimusEnablement=0x00000001; } extern "C" { OSG_EXPORT DWORD NvOptimusEnablement=0x00000001; }
@ -32,6 +29,9 @@ extern "C" { OSG_EXPORT DWORD NvOptimusEnablement=0x00000001; }
extern "C" { int NvOptimusEnablement=0x00000001; } extern "C" { int NvOptimusEnablement=0x00000001; }
#endif #endif
using namespace osg;
using namespace std;
void DisplaySettings::setNvOptimusEnablement(int value) void DisplaySettings::setNvOptimusEnablement(int value)
{ {
NvOptimusEnablement = value; NvOptimusEnablement = value;

View File

@ -235,7 +235,6 @@
#include "CameraConfig.h" #include "CameraConfig.h"
using namespace std;
using namespace osgProducer; using namespace osgProducer;
static void ConfigParser_error( const char * ); static void ConfigParser_error( const char * );

View File

@ -34,7 +34,6 @@
#include <Producer/CameraConfig> #include <Producer/CameraConfig>
using namespace std;
using namespace Producer; using namespace Producer;
static void ConfigParser_error( const char * ); static void ConfigParser_error( const char * );