--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -61,7 +61,7 @@
 #   include <sys/types.h>
 #endif
 
-#if defined(__linux) || defined(__sun) || defined(_AIX) || defined(__GLIBC__)
+#if defined(__linux__) || defined(__sun) || defined(_AIX) || defined(__GLIBC__)
 #   include <grp.h> // for initgroups
 #endif
 
--- a/cpp/src/Ice/Network.cpp
+++ b/cpp/src/Ice/Network.cpp
@@ -46,7 +46,7 @@
 #   include <sys/ioctl.h>
 #endif
 
-#if defined(__linux) || defined(__APPLE__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
 #  include <ifaddrs.h>
 #elif defined(__sun)
 #  include <sys/sockio.h>
@@ -346,7 +346,7 @@
 
         free(adapter_addresses);
     }
-#elif defined(__linux) || defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
     struct ifaddrs* ifap;
     if(::getifaddrs(&ifap) == SOCKET_ERROR)
     {
@@ -648,7 +648,7 @@
     //
     if(isAddr)
     {
-#  if defined(__linux) || defined(__APPLE__) || defined(__FreeBSD__)
+#  if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
         struct ifaddrs* ifap;
         if(::getifaddrs(&ifap) != SOCKET_ERROR)
         {
@@ -2653,7 +2653,7 @@
         }
     }
 
-#if defined(__linux)
+#if defined(__linux__)
     //
     // Prevent self connect (self connect happens on Linux when a client tries to connect to
     // a server which was just deactivated if the client socket re-uses the same ephemeral
@@ -2722,7 +2722,7 @@
         }
     }
 
-#if defined(__linux)
+#if defined(__linux__)
     //
     // Prevent self connect (self connect happens on Linux when a client tries to connect to
     // a server which was just deactivated if the client socket re-uses the same ephemeral
--- a/cpp/src/IceGrid/Activator.cpp
+++ b/cpp/src/IceGrid/Activator.cpp
@@ -32,7 +32,7 @@
 #endif
 #endif
 
-#if defined(__linux) || defined(__sun) || defined(_AIX) || defined(__GLIBC__)
+#if defined(__linux__) || defined(__sun) || defined(_AIX) || defined(__GLIBC__)
 #   include <grp.h> // for setgroups
 #endif
 
@@ -1413,7 +1413,7 @@
     try
     {
         int status;
-#if defined(__linux)
+#if defined(__linux__)
         int nRetry = 0;
         while(true) // The while loop is necessary for the linux workaround.
         {
--- a/cpp/src/IceGrid/PlatformInfo.cpp
+++ b/cpp/src/IceGrid/PlatformInfo.cpp
@@ -333,7 +333,7 @@
     {
 #if defined(_WIN32)
         _nProcessorSockets = getSocketCount(_traceLevels->logger);
-#elif defined(__linux)
+#elif defined(__linux__)
         ifstream is("/proc/cpuinfo");
         set<string> ids;
 
@@ -484,7 +484,7 @@
     info.avg1 = static_cast<float>(_last1Total) / _usages1.size() / 100.0f;
     info.avg5 = static_cast<float>(_last5Total) / _usages5.size() / 100.0f;
     info.avg15 = static_cast<float>(_last15Total) / _usages15.size() / 100.0f;
-#elif defined(__sun) || defined(__linux) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__sun) || defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
     //
     // We use the load average divided by the number of
     // processors to figure out if the machine is busy or
--- a/cpp/src/IceSSL/OpenSSLEngine.cpp
+++ b/cpp/src/IceSSL/OpenSSLEngine.cpp
@@ -84,7 +84,7 @@
     // On some platforms, pthread_t is a pointer to a per-thread structure.
     //
     return reinterpret_cast<unsigned long>(pthread_self());
-#  elif defined(__linux) || defined(__sun) || defined(__hpux) || defined(_AIX) || defined(__GLIBC__)
+#  elif defined(__linux__) || defined(__sun) || defined(__hpux) || defined(_AIX) || defined(__GLIBC__)
     //
     // On Linux, Solaris, HP-UX and AIX, pthread_t is an integer.
     //
