From 9fb010fadd1435a12c64f75bcacfa82e9b3b0d7d Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Tue, 16 Mar 2021 21:46:50 +0000 Subject: [PATCH] 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 --- src/osg/DisplaySettings.cpp | 6 +++--- src/osgPlugins/cfg/ConfigParser.cpp | 1 - src/osgPlugins/cfg/ConfigParser.y | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/osg/DisplaySettings.cpp b/src/osg/DisplaySettings.cpp index c65a808b1..aaf9638bb 100644 --- a/src/osg/DisplaySettings.cpp +++ b/src/osg/DisplaySettings.cpp @@ -22,9 +22,6 @@ #include #include -using namespace osg; -using namespace std; - #if defined(_WIN32) && !defined(__CYGWIN__) #include extern "C" { OSG_EXPORT DWORD NvOptimusEnablement=0x00000001; } @@ -32,6 +29,9 @@ extern "C" { OSG_EXPORT DWORD NvOptimusEnablement=0x00000001; } extern "C" { int NvOptimusEnablement=0x00000001; } #endif +using namespace osg; +using namespace std; + void DisplaySettings::setNvOptimusEnablement(int value) { NvOptimusEnablement = value; diff --git a/src/osgPlugins/cfg/ConfigParser.cpp b/src/osgPlugins/cfg/ConfigParser.cpp index d42171004..8a6807eaf 100644 --- a/src/osgPlugins/cfg/ConfigParser.cpp +++ b/src/osgPlugins/cfg/ConfigParser.cpp @@ -235,7 +235,6 @@ #include "CameraConfig.h" -using namespace std; using namespace osgProducer; static void ConfigParser_error( const char * ); diff --git a/src/osgPlugins/cfg/ConfigParser.y b/src/osgPlugins/cfg/ConfigParser.y index cf9adf507..f6a28f766 100644 --- a/src/osgPlugins/cfg/ConfigParser.y +++ b/src/osgPlugins/cfg/ConfigParser.y @@ -34,7 +34,6 @@ #include -using namespace std; using namespace Producer; static void ConfigParser_error( const char * );