THRIFT-2045: C++ compiler warning and build cleanup (again)
Client: cpp
Patch: Ben Craig
diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc
index b9f7513..4ce22b4 100755
--- a/compiler/cpp/src/main.cc
+++ b/compiler/cpp/src/main.cc
@@ -39,13 +39,14 @@
 #include <errno.h>
 #include <limits.h>
 
-#ifdef MINGW
+#ifdef _WIN32
 # include <windows.h> /* for GetFullPathName */
 #endif
 
 // Careful: must include globals first for extern definitions
 #include "globals.h"
 
+#include "platform.h"
 #include "main.h"
 #include "parse/t_program.h"
 #include "parse/t_scope.h"
@@ -161,11 +162,11 @@
 bool gen_recurse = false;
 
 /**
- * MinGW doesn't have realpath, so use fallback implementation in that case,
+ * Win32 doesn't have realpath, so use fallback implementation in that case,
  * otherwise this just calls through to realpath
  */
 char *saferealpath(const char *path, char *resolved_path) {
-#ifdef MINGW
+#ifdef _WIN32
   char buf[MAX_PATH];
   char* basename;
   DWORD len = GetFullPathName(path, MAX_PATH, buf, &basename);
@@ -190,7 +191,7 @@
 }
 
 bool check_is_directory(const char *dir_name) {
-#ifdef MINGW
+#ifdef _WIN32
   DWORD attributes = ::GetFileAttributesA(dir_name);
   if(attributes == INVALID_FILE_ATTRIBUTES) {
     fprintf(stderr, "Output directory %s is unusable: GetLastError() = %ld\n", dir_name, GetLastError());
@@ -336,7 +337,7 @@
   // Absolute path? Just try that
   if (filename[0] == '/') {
     // Realpath!
-    char rp[PATH_MAX];
+    char rp[THRIFT_PATH_MAX];
     if (saferealpath(filename.c_str(), rp) == NULL) {
       pwarning(0, "Cannot open include file %s\n", filename.c_str());
       return std::string();
@@ -358,7 +359,7 @@
       string sfilename = *(it) + "/" + filename;
 
       // Realpath!
-      char rp[PATH_MAX];
+      char rp[THRIFT_PATH_MAX];
       if (saferealpath(sfilename.c_str(), rp) == NULL) {
         continue;
       }
@@ -757,8 +758,8 @@
       }
     }
     if (!found) {
-      throw "type error: const " + name + " was declared as type " 
-        + type->get_name() + " which is an enum, but " 
+      throw "type error: const " + name + " was declared as type "
+        + type->get_name() + " which is an enum, but "
         + value->get_identifier() + " is not a valid value for that enum";
     }
   } else if (type->is_struct() || type->is_xception()) {
@@ -1066,7 +1067,7 @@
         }
         out_path = arg;
 
-#ifdef MINGW
+#ifdef _WIN32
         //strip out trailing \ on Windows
         int last = out_path.length()-1;
         if (out_path[last] == '\\')
@@ -1104,7 +1105,7 @@
   }
 
   // Real-pathify it
-  char rp[PATH_MAX];
+  char rp[THRIFT_PATH_MAX];
   if (argv[i] == NULL) {
     fprintf(stderr, "Missing file name\n");
     usage();