From dbae70e786e7cafe23bc9520acc91aacc76d5c10 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Mon, 19 Dec 2011 12:06:17 +0000
Subject: [PATCH] one more try to fix the intptr_t problem

---
 CMakeLists.txt            |  5 +++++
 Common/GmshConfig.h.in    |  1 +
 Common/ListUtils.cpp      | 14 ++++++--------
 Common/avl.cpp            | 15 ++++++---------
 Fltk/FlGui.cpp            |  7 ++++++-
 Fltk/menuWindow.cpp       |  8 ++++++--
 Fltk/pluginWindow.cpp     |  7 ++++++-
 Fltk/visibilityWindow.cpp |  7 ++++++-
 8 files changed, 42 insertions(+), 22 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7712dedd99..0864cd3b04 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -820,6 +820,11 @@ if(NOT SOCKLEN_T_SIZE)
 endif(NOT SOCKLEN_T_SIZE)
 set(CMAKE_EXTRA_INCLUDE_FILES)
 
+check_type_size(intptr_t INTPTR_T_SIZE)
+if(NOT INTPTR_T_SIZE)
+  set_config_option(HAVE_NO_INTPTR_T "NoIntptrT")
+endif(NOT INTPTR_T_SIZE)
+
 check_include_file(dlfcn.h DLFCN_H)
 if(DLFCN_H)
   set_config_option(HAVE_DLOPEN "Dlopen")
diff --git a/Common/GmshConfig.h.in b/Common/GmshConfig.h.in
index 30771075fb..b5bd6e3dce 100644
--- a/Common/GmshConfig.h.in
+++ b/Common/GmshConfig.h.in
@@ -36,6 +36,7 @@
 #cmakedefine HAVE_MPI
 #cmakedefine HAVE_NATIVE_FILE_CHOOSER
 #cmakedefine HAVE_NETGEN
+#cmakedefine HAVE_NO_INTPTR_T
 #cmakedefine HAVE_NO_SOCKLEN_T
 #cmakedefine HAVE_NO_VSNPRINTF
 #cmakedefine HAVE_OCC
diff --git a/Common/ListUtils.cpp b/Common/ListUtils.cpp
index 7284a29cd7..beb8ecaf1b 100644
--- a/Common/ListUtils.cpp
+++ b/Common/ListUtils.cpp
@@ -7,19 +7,17 @@
 //   Marc Ume
 //
 
+#include "GmshConfig.h"
+#if defined(HAVE_NO_INTPTR_T)
+typedef unsigned intptr_t;
+#else
+#include <stdint.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
 #include <sys/types.h>
-#ifdef _MSC_VER
-typedef __int32 int32_t;
-typedef unsigned __int32 uint32_t;
-typedef __int64 int64_t;
-typedef unsigned __int64 uint64_t;
-#else
-#include <stdint.h>
-#endif
 #include "MallocUtils.h"
 #include "ListUtils.h"
 #include "TreeUtils.h"
diff --git a/Common/avl.cpp b/Common/avl.cpp
index 618f7fc620..3bccf2cbdf 100644
--- a/Common/avl.cpp
+++ b/Common/avl.cpp
@@ -25,16 +25,13 @@
 
 // Modified for Gmsh (C++ and 64 bit compatibility)
 
-#include <stdio.h>
-#ifdef _MSC_VER
-typedef __int32 int32_t;
-typedef unsigned __int32 uint32_t;
-typedef __int64 int64_t;
-typedef unsigned __int64 uint64_t;
-#else
-#include <stdint.h>
+#include "GmshConfig.h"
+#if defined(HAVE_NO_INTPTR_T)
+typedef unsigned intptr_t;
+#else
+#include <stdint.h>
 #endif
-
+#include <stdio.h>
 #include "avl.h"
 #include "MallocUtils.h"
 
diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp
index cf769b728c..ea0dff1db5 100644
--- a/Fltk/FlGui.cpp
+++ b/Fltk/FlGui.cpp
@@ -3,9 +3,14 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
+#include "GmshConfig.h"
+#if defined(HAVE_NO_INTPTR_T)
+typedef unsigned intptr_t;
+#else
+#include <stdint.h>
+#endif
 #include <sstream>
 #include <string.h>
-#include <stdint.h>
 #include <FL/Fl.H>
 #include <FL/Fl_Tooltip.H>
 #include <FL/Fl_Shared_Image.H>
diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp
index c1a7c9481e..caac5e5faa 100644
--- a/Fltk/menuWindow.cpp
+++ b/Fltk/menuWindow.cpp
@@ -3,15 +3,19 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
+#include "GmshConfig.h"
+#if defined(HAVE_NO_INTPTR_T)
+typedef unsigned intptr_t;
+#else
+#include <stdint.h>
+#endif
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <stdint.h>
 #include <time.h>
 #include <FL/Fl_Box.H>
 #include <FL/fl_ask.H>
 #include <FL/filename.H>
-#include "GmshConfig.h"
 #include "GmshMessage.h"
 #include "GmshSocket.h"
 #include "FlGui.h"
diff --git a/Fltk/pluginWindow.cpp b/Fltk/pluginWindow.cpp
index 1ca1a15819..aa9296775b 100644
--- a/Fltk/pluginWindow.cpp
+++ b/Fltk/pluginWindow.cpp
@@ -3,9 +3,14 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
+#include "GmshConfig.h"
+#if defined(HAVE_NO_INTPTR_T)
+typedef unsigned intptr_t;
+#else
+#include <stdint.h>
+#endif
 #include <vector>
 #include <string.h>
-#include <stdint.h>
 #include <FL/Fl_Return_Button.H>
 #include <FL/Fl_Group.H>
 #include <FL/Fl_Value_Input.H>
diff --git a/Fltk/visibilityWindow.cpp b/Fltk/visibilityWindow.cpp
index 77e35cd451..069cfdd071 100644
--- a/Fltk/visibilityWindow.cpp
+++ b/Fltk/visibilityWindow.cpp
@@ -3,11 +3,16 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to <gmsh@geuz.org>.
 
+#include "GmshConfig.h"
+#if defined(HAVE_NO_INTPTR_T)
+typedef unsigned intptr_t;
+#else
+#include <stdint.h>
+#endif
 #include <string>
 #include <sstream>
 #include <map>
 #include <vector>
-#include <stdint.h>
 #include <string.h>
 #include <FL/Fl_Tabs.H>
 #include <FL/Fl_Box.H>
-- 
GitLab