diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7712dedd99d9b19d3f562dd826a2e2fd04c49353..0864cd3b04aea614f4be69f5325e5a0c9345feb5 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 30771075fba98347d1ae18c1e9db43bca4e53ec5..b5bd6e3dcec3a4a0d9e7159f93eaa6bd2bd240d9 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 7284a29cd7f96c49962715781a85009a373384d2..beb8ecaf1bfc4da6587e759e452f900c3b33225a 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 618f7fc6206a7daf821f495365c9bdefab6127be..3bccf2cbdf6b7a5c1c3062b1bdf4d1b10c1c21cd 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 cf769b728c4b9e35b873fbd9ed58524167870641..ea0dff1db5fdb5482874fe13e2843d5745599ca0 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 c1a7c9481e40120b8de3964f3f18a45fb503b49c..caac5e5faa4140eff924764c4e1a8eac8692542c 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 1ca1a15819513231a5937ff1a210196ac870e26b..aa9296775ba6c098bcec4533376a41234bd5bdfe 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 77e35cd4514f8f8ae0f058a306aeda4363c6fdd1..069cfdd071d3ce8197fc62bc1aa39e9166ff69ae 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>