--- a/src/liboslexec/shadingsys.cpp
+++ b/src/liboslexec/shadingsys.cpp
@@ -34,8 +34,10 @@
 #include <OpenEXR/ImfChannelList.h>  // Just for OPENEXR_VERSION_STRING
 
 // avoid naming conflicts with MSVC macros
-#ifdef _MSC_VER
+#ifdef _WIN32
 #    undef RGB
+#endif
+#ifdef _MSC_VER
 // We use some of the iso646.h macro names later on in this file. For
 // some compilers (MSVS, I'm looking at you) this is trouble. I don't know
 // how or why that header would have been included here, but it did for at
