From e2cbc7557b57a6c6ea99bb8182aec90818beee2a Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 23 Sep 2011 09:59:27 +0000
Subject: [PATCH] replace <inttypes.h> with <stdint.h> (hopefully better for
 some MSVC versions) + fix misc compile errors with MSVC (thanks to Michel)

---
 Common/ListUtils.cpp       |  2 +-
 Common/avl.cpp             |  2 +-
 Fltk/FlGui.cpp             |  2 +-
 Fltk/menuWindow.cpp        |  2 +-
 Fltk/optionWindow.cpp      |  2 +-
 Fltk/pluginWindow.cpp      |  2 +-
 Fltk/solverWindow.cpp      |  2 +-
 Fltk/visibilityWindow.cpp  |  2 +-
 Geo/CellComplex.cpp        |  7 ++++---
 Geo/GeomMeshMatcher.cpp    |  3 +--
 Mesh/QuadTriExtruded3D.cpp |  6 +++---
 Mesh/meshGFaceLloyd.cpp    |  4 ++--
 Plugin/NearToFarField.cpp  | 10 ++++++++--
 13 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/Common/ListUtils.cpp b/Common/ListUtils.cpp
index 9c0ea5aac3..f9ef056c18 100644
--- a/Common/ListUtils.cpp
+++ b/Common/ListUtils.cpp
@@ -12,7 +12,7 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/types.h>
-#include <inttypes.h>
+#include <stdint.h>
 #include "MallocUtils.h"
 #include "ListUtils.h"
 #include "TreeUtils.h"
diff --git a/Common/avl.cpp b/Common/avl.cpp
index 3ed44a41d9..d49893c671 100644
--- a/Common/avl.cpp
+++ b/Common/avl.cpp
@@ -26,7 +26,7 @@
 // Modified for Gmsh (C++ and 64 bit compatibility)
 
 #include <stdio.h>
-#include <inttypes.h>
+#include <stdint.h>
 
 #include "avl.h"
 #include "MallocUtils.h"
diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp
index df0f8a5a1c..23892ba739 100644
--- a/Fltk/FlGui.cpp
+++ b/Fltk/FlGui.cpp
@@ -5,7 +5,7 @@
 
 #include <sstream>
 #include <string.h>
-#include <inttypes.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 609135a558..8678b78674 100644
--- a/Fltk/menuWindow.cpp
+++ b/Fltk/menuWindow.cpp
@@ -6,7 +6,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <inttypes.h>
+#include <stdint.h>
 #include <time.h>
 #include <FL/Fl_Box.H>
 #include <FL/fl_ask.H>
diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp
index 695721de50..93c1111885 100644
--- a/Fltk/optionWindow.cpp
+++ b/Fltk/optionWindow.cpp
@@ -4,7 +4,7 @@
 // bugs and problems to <gmsh@geuz.org>.
 
 #include <string.h>
-#include <inttypes.h>
+#include <stdint.h>
 #include <FL/Fl_Tabs.H>
 #include <FL/Fl_Scroll.H>
 #include <FL/Fl_Color_Chooser.H>
diff --git a/Fltk/pluginWindow.cpp b/Fltk/pluginWindow.cpp
index 7d4881571b..1ca1a15819 100644
--- a/Fltk/pluginWindow.cpp
+++ b/Fltk/pluginWindow.cpp
@@ -5,7 +5,7 @@
 
 #include <vector>
 #include <string.h>
-#include <inttypes.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/solverWindow.cpp b/Fltk/solverWindow.cpp
index 3f91ce387f..2ef8edd82f 100644
--- a/Fltk/solverWindow.cpp
+++ b/Fltk/solverWindow.cpp
@@ -4,7 +4,7 @@
 // bugs and problems to <gmsh@geuz.org>.
 
 #include <string.h>
-#include <inttypes.h>
+#include <stdint.h>
 #include <FL/Fl_Tabs.H>
 #include <FL/Fl_Box.H>
 #include <FL/Fl_Return_Button.H>
diff --git a/Fltk/visibilityWindow.cpp b/Fltk/visibilityWindow.cpp
index ead516741f..f2033d8749 100644
--- a/Fltk/visibilityWindow.cpp
+++ b/Fltk/visibilityWindow.cpp
@@ -7,7 +7,7 @@
 #include <sstream>
 #include <map>
 #include <vector>
-#include <inttypes.h>
+#include <stdint.h>
 #include <string.h>
 #include <FL/Fl_Tabs.H>
 #include <FL/Fl_Box.H>
diff --git a/Geo/CellComplex.cpp b/Geo/CellComplex.cpp
index ffdf69bac9..c2c147c012 100644
--- a/Geo/CellComplex.cpp
+++ b/Geo/CellComplex.cpp
@@ -603,8 +603,8 @@ int CellComplex::saveComplex(std::string filename)
 
   printf("Wrote %d cells to '%s' \n", 
 	 getSize(0)+getSize(1)+getSize(2)+getSize(3), filename.c_str());
-
-	 return 1;*/
+  */
+  return 1;
 }
 
 int CellComplex::loadComplex(std::string filename)
@@ -676,5 +676,6 @@ int CellComplex::loadComplex(std::string filename)
   }
 
   fclose(fp);
-  return 1;*/
+*/
+  return 1;
 }
diff --git a/Geo/GeomMeshMatcher.cpp b/Geo/GeomMeshMatcher.cpp
index 2d524a234f..5f85e178d1 100644
--- a/Geo/GeomMeshMatcher.cpp
+++ b/Geo/GeomMeshMatcher.cpp
@@ -588,10 +588,9 @@ int GeomMeshMatcher::forceTomatch(GModel *geom, GModel *mesh, const double TOL)
     }
   }  
   geom->writeMSH("hopla.msh",2.2,false,false,true);
+  return 0;
 }
 
-
-
 int GeomMeshMatcher::match(GModel *geom, GModel *mesh)
 {
   mesh->createTopologyFromMesh();
diff --git a/Mesh/QuadTriExtruded3D.cpp b/Mesh/QuadTriExtruded3D.cpp
index 2b6b0d2de4..b1dbb64fe6 100644
--- a/Mesh/QuadTriExtruded3D.cpp
+++ b/Mesh/QuadTriExtruded3D.cpp
@@ -183,7 +183,7 @@ static int get2DExtrudedVertices( MElement *elem, ExtrudeParams *ep, unsigned in
 
   std::set<MVertex *, MVertexLessThanLexicographic>::iterator itp;
   int sz = source_verts.size();
-  double x[sz], y[sz], z[sz];
+  std::vector<double> x(sz), y(sz), z(sz);
   for( int p = 0; p < sz; p++ ){
     x[p] = source_verts[p]->x();
     y[p] = source_verts[p]->y();
@@ -413,9 +413,9 @@ static std::map<std::string, std::vector<int> > getFaceTypes(GRegion *gr, MEleme
   }
 
   // create an array that holds info about whether a face touches a boundary
-  int touch_bnd[n_lat];
+  std::vector<int> touch_bnd(n_lat);
 
-  fill_touch_bnd(touch_bnd, vert_bnd, n_lat);    
+  fill_touch_bnd(&touch_bnd[0], vert_bnd, n_lat);
    
   // Classify the laterals of each little mesh volume:
 
diff --git a/Mesh/meshGFaceLloyd.cpp b/Mesh/meshGFaceLloyd.cpp
index 259efea9e3..27aae49d74 100644
--- a/Mesh/meshGFaceLloyd.cpp
+++ b/Mesh/meshGFaceLloyd.cpp
@@ -215,7 +215,7 @@ void smoothing::optimize_face(GFace* gf){
   double epsf;
   double epsx;
   lpcvt obj;
-  double initial_conditions[2*triangulator.numPoints];
+  std::vector<double> initial_conditions(2*triangulator.numPoints);
   alglib::ae_int_t maxits;
   alglib::minlbfgsstate state;
   alglib::minlbfgsreport rep;
@@ -245,7 +245,7 @@ void smoothing::optimize_face(GFace* gf){
 	}
   }
 	
-  x.setcontent(2*num_interior,initial_conditions);
+  x.setcontent(2*num_interior, &initial_conditions[0]);
 
   octree = backgroundMesh::current()->get_octree();	
 	
diff --git a/Plugin/NearToFarField.cpp b/Plugin/NearToFarField.cpp
index 241806aa0b..08262a265c 100644
--- a/Plugin/NearToFarField.cpp
+++ b/Plugin/NearToFarField.cpp
@@ -110,13 +110,17 @@ double GMSH_NearToFarFieldPlugin::getFarField(PViewData *eData, PViewData *hData
       int numComp  = eData->getNumComponents(0, ent, ele);
       if(numComp != 3) continue ;
       int numNodes = eData->getNumNodes(0, ent, ele);
-      double x[numNodes], y[numNodes], z[numNodes] ;
-      int tag[numNodes];
+      std::vector<double> x(numNodes), y(numNodes), z(numNodes);
+      std::vector<int> tag(numNodes);
 
       for(int nod = 0; nod < numNodes; nod++)
         tag[nod] = eData->getNode(0, ent, ele, nod, x[nod], y[nod], z[nod]);
       double n[3] = {0.,0.,0.};
       normal3points(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2], n); 
+
+      Msg::Error("FIXME JS and MS computation need to be recoded");
+      // cannot allocate like this + fix numSteps
+      /* 
       double Js[numSteps][numNodes*numComp], Ms[numSteps][numNodes*numComp] ;
 
       for(int step = 0; step < numSteps; step++){
@@ -159,6 +163,8 @@ double GMSH_NearToFarFieldPlugin::getFarField(PViewData *eData, PViewData *hData
 
         eData->tagNode(0, ent, ele, nod, 1);
       }
+      */
+
     }
   }
   
-- 
GitLab