diff --git a/Common/gmsh.cpp b/Common/gmsh.cpp
index f2426f2d2c916b7c7c40447abb9429c2713d8e42..b28ca2aa7ed376ccd194ea51b31a9c1aed213b27 100644
--- a/Common/gmsh.cpp
+++ b/Common/gmsh.cpp
@@ -28,6 +28,10 @@
 #include "Field.h"
 #endif
 
+#define GMSH_API std::vector<int>
+#define GMSH_OK std::vector<int>(1, 0)
+#define GMSH_ERROR(n) std::vector<int>(1, n)
+
 static int _initialized = 0;
 
 static bool isInitialized()
@@ -43,52 +47,60 @@ static bool isInitialized()
 
 // gmsh
 
-int gmshInitialize(int argc, char **argv)
+GMSH_API gmshInitialize(int argc, char **argv)
 {
   if(_initialized){
     Msg::Error("Gmsh has aleady been initialized");
-    return 1;
+    return GMSH_ERROR(1);
   }
   if(GmshInitialize(argc, argv)){
     _initialized = 1;
-    return 0;
+    return GMSH_OK;
   }
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshFinalize()
+GMSH_API gmshFinalize()
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   if(GmshFinalize()){
     _initialized = 0;
-    return 0;
+    return GMSH_OK;
   }
   Msg::Error("Something went wrong when finalizing Gmsh");
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshOpen(const std::string &fileName)
+GMSH_API gmshOpen(const std::string &fileName)
 {
-  if(!isInitialized()) return -1;
-  return !GmshOpenProject(fileName);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  if(GmshOpenProject(fileName))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshMerge(const std::string &fileName)
+GMSH_API gmshMerge(const std::string &fileName)
 {
-  if(!isInitialized()) return -1;
-  return !GmshMergeFile(fileName);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  if(GmshMergeFile(fileName))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshExport(const std::string &fileName)
+GMSH_API gmshExport(const std::string &fileName)
 {
-  if(!isInitialized()) return -1;
-  return !GmshWriteFile(fileName);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  if(GmshWriteFile(fileName))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshClear()
+GMSH_API gmshClear()
 {
-  if(!isInitialized()) return -1;
-  return !GmshClearProject();
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  if(GmshClearProject())
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
 // gmshOption
@@ -118,87 +130,97 @@ static void splitOptionName(const std::string &fullName, std::string &category,
              name.c_str(), index);
 }
 
-int gmshOptionSetNumber(const std::string &name, const double value)
+GMSH_API gmshOptionSetNumber(const std::string &name, const double value)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   std::string c, n;
   int i;
   splitOptionName(name, c, n, i);
-  return !GmshSetOption(c, n, value, i);
+  if(GmshSetOption(c, n, value, i))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshOptionGetNumber(const std::string &name, double &value)
+GMSH_API gmshOptionGetNumber(const std::string &name, double &value)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   std::string c, n;
   int i;
   splitOptionName(name, c, n, i);
-  return !GmshGetOption(c, n, value, i);
+  if(GmshGetOption(c, n, value, i))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshOptionSetString(const std::string &name, const std::string &value)
+GMSH_API gmshOptionSetString(const std::string &name, const std::string &value)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   std::string c, n;
   int i;
   splitOptionName(name, c, n, i);
-  return !GmshSetOption(c, n, value, i);
+  if(GmshSetOption(c, n, value, i))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshOptionGetString(const std::string &name, std::string &value)
+GMSH_API gmshOptionGetString(const std::string &name, std::string &value)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   std::string c, n;
   int i;
   splitOptionName(name, c, n, i);
-  return !GmshGetOption(c, n, value, i);
+  if(GmshGetOption(c, n, value, i))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
 // gmshModel
 
-int gmshModelCreate(const std::string &name)
+GMSH_API gmshModelCreate(const std::string &name)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GModel *m = new GModel(name);
-  return m ? 0 : 1;
+  if(m)
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelSetCurrent(const std::string &name)
+GMSH_API gmshModelSetCurrent(const std::string &name)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GModel *m = GModel::findByName(name);
   if(m){
     GModel::setCurrent(m);
-    return 0;
+    return GMSH_OK;
   }
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelDestroy()
+GMSH_API gmshModelDestroy()
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GModel *m = GModel::current();
   if(m){
     delete m;
-    return 0;
+    return GMSH_OK;
   }
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGetEntities(vector_pair &dimTags, const int dim)
+GMSH_API gmshModelGetEntities(vector_pair &dimTags, const int dim)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   dimTags.clear();
   std::vector<GEntity*> entities;
   GModel::current()->getEntities(entities, dim);
   for(unsigned int i = 0; i < entities.size(); i++)
     dimTags.push_back(std::pair<int, int>(entities[i]->dim(), entities[i]->tag()));
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelGetPhysicalGroups(vector_pair &dimTags, const int dim)
+GMSH_API gmshModelGetPhysicalGroups(vector_pair &dimTags, const int dim)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   dimTags.clear();
   std::map<int, std::vector<GEntity*> > groups[4];
   GModel::current()->getPhysicalGroups(groups);
@@ -209,25 +231,26 @@ int gmshModelGetPhysicalGroups(vector_pair &dimTags, const int dim)
         dimTags.push_back(std::pair<int, int>(d, it->first));
     }
   }
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelAddPhysicalGroup(const int dim, const int tag, const std::vector<int> &tags)
+GMSH_API gmshModelAddPhysicalGroup(const int dim, const int tag,
+                                   const std::vector<int> &tags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   bool r = GModel::current()->getGEOInternals()->modifyPhysicalGroup
     (dim, tag, 0, tags);
   if(r){
     GModel::current()->getGEOInternals()->synchronize(GModel::current());
-    return 0;
+    return GMSH_OK;
   }
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGetEntitiesForPhysicalGroup(const int dim, const int tag,
-                                         std::vector<int> &tags)
+GMSH_API gmshModelGetEntitiesForPhysicalGroup(const int dim, const int tag,
+                                              std::vector<int> &tags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   tags.clear();
   std::map<int, std::vector<GEntity*> > groups;
   GModel::current()->getPhysicalGroups(dim, groups);
@@ -236,105 +259,110 @@ int gmshModelGetEntitiesForPhysicalGroup(const int dim, const int tag,
     for(unsigned j = 0; j < it->second.size(); j++)
       tags.push_back(it->second[j]->tag());
   }
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelSetPhysicalName(const int dim, const int tag, const std::string &name)
+GMSH_API gmshModelSetPhysicalName(const int dim, const int tag,
+                                  const std::string &name)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GModel::current()->setPhysicalName(name, dim, tag);
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelGetPhysicalName(const int dim, const int tag, std::string &name)
+GMSH_API gmshModelGetPhysicalName(const int dim, const int tag,
+                                  std::string &name)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   name = GModel::current()->getPhysicalName(dim, tag);
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelGetVertexCoordinates(const int tag, double &x, double &y, double &z)
+GMSH_API gmshModelGetVertexCoordinates(const int tag, double &x, double &y,
+                                       double &z)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GVertex *gv = GModel::current()->getVertexByTag(tag);
   if(gv){
     x = gv->x();
     y = gv->y();
     z = gv->z();
-    return 0;
+    return GMSH_OK;
   }
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGetBoundary(const vector_pair &inDimTags, vector_pair &outDimTags,
-                         const bool combined, const bool oriented, const bool recursive)
+GMSH_API gmshModelGetBoundary(const vector_pair &inDimTags, vector_pair &outDimTags,
+                              const bool combined, const bool oriented,
+                              const bool recursive)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   outDimTags.clear();
   bool r = GModel::current()->getBoundaryTags(inDimTags, outDimTags, combined,
                                               oriented, recursive);
-  if(r) return 0;
-  return 1;
+  if(r) return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGetEntitiesInBoundingBox(const double x1, const double y1, const double z1,
-                                      const double x2, const double y2, const double z2,
-                                      vector_pair &dimTags, const int dim)
+GMSH_API gmshModelGetEntitiesInBoundingBox(const double x1, const double y1,
+                                           const double z1, const double x2,
+                                           const double y2, const double z2,
+                                           vector_pair &dimTags, const int dim)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   dimTags.clear();
   SBoundingBox3d box(x1, y1, z1, x2, y2, z2);
   std::vector<GEntity*> entities;
   GModel::current()->getEntitiesInBox(entities, box, dim);
   for(unsigned int i = 0; i < entities.size(); i++)
     dimTags.push_back(std::pair<int, int>(entities[i]->dim(), entities[i]->tag()));
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelGetBoundingBox(const int dim, const int tag, double &x1, double &y1,
-                            double &z1, double &x2, double &y2, double &z2)
+GMSH_API gmshModelGetBoundingBox(const int dim, const int tag, double &x1, double &y1,
+                                 double &z1, double &x2, double &y2, double &z2)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-  if(!ge) return 1;
+  if(!ge) return GMSH_ERROR(1);
   SBoundingBox3d box = ge->bounds();
-  if(box.empty()) return 2;
+  if(box.empty()) return GMSH_ERROR(2);
   x1 = box.min().x();
   y1 = box.min().y();
   z1 = box.min().z();
   x2 = box.max().x();
   y2 = box.max().y();
   z2 = box.max().z();
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelRemove(const vector_pair &dimTags, const bool recursive)
+GMSH_API gmshModelRemove(const vector_pair &dimTags, const bool recursive)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GModel::current()->remove(dimTags, recursive);
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelMesh(int dim)
+GMSH_API gmshModelMesh(int dim)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GModel *m = GModel::current();
   if(m){
     m->mesh(dim);
-    return 0;
+    return GMSH_OK;
   }
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGetMeshVertices(const int dim, const int tag,
-                             std::vector<int> &vertexTags,
-                             std::vector<double> &coords)
+GMSH_API gmshModelGetMeshVertices(const int dim, const int tag,
+                                  std::vector<int> &vertexTags,
+                                  std::vector<double> &coords)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   vertexTags.clear();
   coords.clear();
   GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-  if(!ge) return 1;
+  if(!ge) return GMSH_ERROR(1);
   for(unsigned int i = 0; i < ge->mesh_vertices.size(); i++){
     MVertex *v = ge->mesh_vertices[i];
     vertexTags.push_back(v->getNum());
@@ -342,7 +370,7 @@ int gmshModelGetMeshVertices(const int dim, const int tag,
     coords.push_back(v->y());
     coords.push_back(v->z());
   }
-  return 0;
+  return GMSH_OK;
 }
 
 template<class T>
@@ -363,16 +391,17 @@ static void addElementInfo(const std::vector<T*> &ele,
   }
 }
 
-int gmshModelGetMeshElements(const int dim, const int tag, std::vector<int> &types,
-                             std::vector<std::vector<int> > &elementTags,
-                             std::vector<std::vector<int> > &vertexTags)
+GMSH_API gmshModelGetMeshElements(const int dim, const int tag,
+                                  std::vector<int> &types,
+                                  std::vector<std::vector<int> > &elementTags,
+                                  std::vector<std::vector<int> > &vertexTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   types.clear();
   elementTags.clear();
   vertexTags.clear();
   GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-  if(!ge) return 1;
+  if(!ge) return GMSH_ERROR(1);
   switch(dim){
   case 0: {
     GVertex *v = static_cast<GVertex*>(ge);
@@ -395,27 +424,28 @@ int gmshModelGetMeshElements(const int dim, const int tag, std::vector<int> &typ
     addElementInfo(r->pyramids, types, elementTags, vertexTags);
     break; }
   }
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelSetMeshSize(const vector_pair &dimTags, const double size)
+GMSH_API gmshModelSetMeshSize(const vector_pair &dimTags, const double size)
 {
-  if(!isInitialized()) return -1;
-  int ret = 0;
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  bool ok = true;
   for(unsigned int i = 0; i < dimTags.size(); i++){
     int dim = dimTags[i].first, tag = dimTags[i].second;
-    if(dim != 1) ret = 1;
+    if(dim != 1) ok = false;
     GVertex *gv = GModel::current()->getVertexByTag(tag);
     if(gv) gv->setPrescribedMeshSizeAtVertex(size);
   }
-  return ret;
+  if(ok)
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelSetTransfiniteLine(const int tag, const int nPoints,
-                                const std::string &type,
-                                const double coef)
+GMSH_API gmshModelSetTransfiniteLine(const int tag, const int nPoints,
+                                     const std::string &type, const double coef)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GEdge *ge = GModel::current()->getEdgeByTag(tag);
   if(ge){
     ge->meshAttributes.method = MESH_TRANSFINITE;
@@ -427,15 +457,16 @@ int gmshModelSetTransfiniteLine(const int tag, const int nPoints,
     ge->meshAttributes.coeffTransfinite = std::abs(coef);
     // in .geo file we use a negative tag to do this trick; it's a bad idea
     if(coef < 0) ge->meshAttributes.typeTransfinite *= -1;
-    return 0;
+    return GMSH_OK;
   }
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelSetTransfiniteSurface(const int tag, const std::string &arrangement,
-                                   const std::vector<int> &cornerTags)
+GMSH_API gmshModelSetTransfiniteSurface(const int tag,
+                                        const std::string &arrangement,
+                                        const std::vector<int> &cornerTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GFace *gf = GModel::current()->getFaceByTag(tag);
   if(gf){
     gf->meshAttributes.method = MESH_TRANSFINITE;
@@ -453,14 +484,15 @@ int gmshModelSetTransfiniteSurface(const int tag, const std::string &arrangement
           gf->meshAttributes.corners.push_back(gv);
       }
     }
-    return 0;
+    return GMSH_OK;
   }
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelSetTransfiniteVolume(const int tag, const std::vector<int> &cornerTags)
+GMSH_API gmshModelSetTransfiniteVolume(const int tag,
+                                       const std::vector<int> &cornerTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GRegion *gr = GModel::current()->getRegionByTag(tag);
   if(gr){
     gr->meshAttributes.method = MESH_TRANSFINITE;
@@ -471,59 +503,59 @@ int gmshModelSetTransfiniteVolume(const int tag, const std::vector<int> &cornerT
           gr->meshAttributes.corners.push_back(gv);
       }
     }
-    return 0;
+    return GMSH_OK;
   }
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelSetRecombine(const int dim, const int tag, const double angle)
+GMSH_API gmshModelSetRecombine(const int dim, const int tag, const double angle)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GFace *gf = GModel::current()->getFaceByTag(tag);
   if(gf){
     gf->meshAttributes.recombine = 1;
     gf->meshAttributes.recombineAngle = angle;
-    return 0;
+    return GMSH_OK;
   }
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelSetSmoothing(const int dim, const int tag, const int val)
+GMSH_API gmshModelSetSmoothing(const int dim, const int tag, const int val)
 {
-  if(!isInitialized()) return -1;
-  if(dim != 2) return 1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  if(dim != 2) return GMSH_ERROR(1);
   GFace *gf = GModel::current()->getFaceByTag(tag);
   if(gf){
     gf->meshAttributes.transfiniteSmoothing = val;
-    return 0;
+    return GMSH_OK;
   }
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelSetReverseMesh(const int dim, const int tag, const bool val)
+GMSH_API gmshModelSetReverseMesh(const int dim, const int tag, const bool val)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   if(dim == 1){
     GEdge *ge = GModel::current()->getEdgeByTag(tag);
     if(ge){
       ge->meshAttributes.reverseMesh = val;
-      return 0;
+      return GMSH_OK;
     }
   }
   else if(dim == 2){
     GFace *gf = GModel::current()->getFaceByTag(tag);
     if(gf){
       gf->meshAttributes.reverseMesh = val;
-      return 0;
+      return GMSH_OK;
     }
   }
-  return 1;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelEmbed(const int dim, const std::vector<int> &tags,
-                   const int inDim, const int inTag)
+GMSH_API gmshModelEmbed(const int dim, const std::vector<int> &tags,
+                        const int inDim, const int inTag)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   if(inDim == 2){
     GFace *gf = GModel::current()->getFaceByTag(inTag);
     if(gf){
@@ -563,114 +595,155 @@ int gmshModelEmbed(const int dim, const std::vector<int> &tags,
       }
     }
   }
-  return 0;
+  return GMSH_OK;
 }
 
 // gmshModelGeo
 
-int gmshModelGeoAddPoint(const int tag, const double x, const double y, const double z,
-                         int &outTag, const double meshSize)
+GMSH_API gmshModelGeoAddPoint(const int tag, const double x, const double y,
+                              const double z, const double meshSize)
 {
-  if(!isInitialized()) return -1;
-  outTag = tag;
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  int outTag = tag;
   double xx = CTX::instance()->geom.scalingFactor * x;
   double yy = CTX::instance()->geom.scalingFactor * y;
   double zz = CTX::instance()->geom.scalingFactor * z;
   double lc = CTX::instance()->geom.scalingFactor * meshSize;
-  return !GModel::current()->getGEOInternals()->addVertex(outTag, xx, yy, zz, lc);
+  if(GModel::current()->getGEOInternals()->addVertex(outTag, xx, yy, zz, lc)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoAddLine(const int tag, const int startTag, const int endTag,
-                        int &outTag)
+GMSH_API gmshModelGeoAddLine(const int tag, const int startTag, const int endTag)
 {
-  if(!isInitialized()) return -1;
-  outTag = tag;
-  return !GModel::current()->getGEOInternals()->addLine(outTag, startTag, endTag);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  int outTag = tag;
+  if(GModel::current()->getGEOInternals()->addLine(outTag, startTag, endTag)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoAddCircleArc(const int tag, const int startTag, const int centerTag,
-                             const int endTag, int &outTag,
-                             const double nx, const double ny, const double nz)
+GMSH_API gmshModelGeoAddCircleArc(const int tag, const int startTag,
+                                  const int centerTag, const int endTag,
+                                  const double nx, const double ny, const double nz)
 {
-  if(!isInitialized()) return -1;
-  outTag = tag;
-  return !GModel::current()->getGEOInternals()->addCircleArc
-    (outTag, startTag, centerTag, endTag, nx, ny, nz);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  int outTag = tag;
+  if(GModel::current()->getGEOInternals()->addCircleArc
+     (outTag, startTag, centerTag, endTag, nx, ny, nz)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoAddEllipseArc(const int tag, const int startTag, const int centerTag,
-                              const int majorTag, const int endTag, int &outTag,
-                              const double nx, const double ny, const double nz)
+GMSH_API gmshModelGeoAddEllipseArc(const int tag, const int startTag,
+                                   const int centerTag, const int majorTag,
+                                   const int endTag, const double nx, const double ny,
+                                   const double nz)
 {
-  if(!isInitialized()) return -1;
-  outTag = tag;
-  return !GModel::current()->getGEOInternals()->addEllipseArc
-    (outTag, startTag, centerTag, majorTag, endTag, nx, ny, nz);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  int outTag = tag;
+  if(GModel::current()->getGEOInternals()->addEllipseArc
+     (outTag, startTag, centerTag, majorTag, endTag, nx, ny, nz)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoAddSpline(const int tag, const std::vector<int> &vertexTags,
-                          int &outTag)
+GMSH_API gmshModelGeoAddSpline(const int tag, const std::vector<int> &vertexTags)
 {
-  if(!isInitialized()) return -1;
-  outTag = tag;
-  return !GModel::current()->getGEOInternals()->addSpline(outTag, vertexTags);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  int outTag = tag;
+  if(GModel::current()->getGEOInternals()->addSpline(outTag, vertexTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoAddBSpline(const int tag, const std::vector<int> &vertexTags,
-                           int &outTag)
+GMSH_API gmshModelGeoAddBSpline(const int tag, const std::vector<int> &vertexTags)
 {
-  if(!isInitialized()) return -1;
-  outTag = tag;
-  return !GModel::current()->getGEOInternals()->addBSpline(outTag, vertexTags);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  int outTag = tag;
+  if(GModel::current()->getGEOInternals()->addBSpline(outTag, vertexTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoAddBezier(const int tag, const std::vector<int> &vertexTags,
-                          int &outTag)
+GMSH_API gmshModelGeoAddBezier(const int tag, const std::vector<int> &vertexTags)
 {
-  if(!isInitialized()) return -1;
-  outTag = tag;
-  return !GModel::current()->getGEOInternals()->addBezier(outTag, vertexTags);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  int outTag = tag;
+  if(GModel::current()->getGEOInternals()->addBezier(outTag, vertexTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoAddLineLoop(const int tag, const std::vector<int> &edgeTags,
-                            int &outTag)
+GMSH_API gmshModelGeoAddLineLoop(const int tag, const std::vector<int> &edgeTags)
 {
-  if(!isInitialized()) return -1;
-  outTag = tag;
-  return !GModel::current()->getGEOInternals()->addLineLoop(outTag, edgeTags);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  int outTag = tag;
+  if(GModel::current()->getGEOInternals()->addLineLoop(outTag, edgeTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoAddPlaneSurface(const int tag, const std::vector<int> &wireTags,
-                                int &outTag)
+GMSH_API gmshModelGeoAddPlaneSurface(const int tag, const std::vector<int> &wireTags)
 {
-  if(!isInitialized()) return -1;
-  outTag = tag;
-  return !GModel::current()->getGEOInternals()->addPlaneSurface(outTag, wireTags);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  int outTag = tag;
+  if(GModel::current()->getGEOInternals()->addPlaneSurface(outTag, wireTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoAddSurfaceFilling(const int tag, const std::vector<int> &wireTags,
-                                  int &outTag, const int sphereCenterTag)
+GMSH_API gmshModelGeoAddSurfaceFilling(const int tag, const std::vector<int> &wireTags,
+                                       const int sphereCenterTag)
 {
-  if(!isInitialized()) return -1;
-  outTag = tag;
-  return !GModel::current()->getGEOInternals()->addSurfaceFilling
-    (outTag, wireTags, sphereCenterTag);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  int outTag = tag;
+  if(GModel::current()->getGEOInternals()->addSurfaceFilling
+     (outTag, wireTags, sphereCenterTag)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoAddSurfaceLoop(const int tag, const std::vector<int> &faceTags,
-                               int &outTag)
+GMSH_API gmshModelGeoAddSurfaceLoop(const int tag, const std::vector<int> &faceTags)
 {
-  if(!isInitialized()) return -1;
-  outTag = tag;
-  return !GModel::current()->getGEOInternals()->addSurfaceLoop(outTag, faceTags);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  int outTag = tag;
+  if(GModel::current()->getGEOInternals()->addSurfaceLoop(outTag, faceTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoAddVolume(const int tag, const std::vector<int> &shellTags,
-                          int &outTag)
+GMSH_API gmshModelGeoAddVolume(const int tag, const std::vector<int> &shellTags)
 {
-  if(!isInitialized()) return -1;
-  outTag = tag;
-  return !GModel::current()->getGEOInternals()->addVolume(outTag, shellTags);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  int outTag = tag;
+  if(GModel::current()->getGEOInternals()->addVolume(outTag, shellTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
 static ExtrudeParams *getExtrudeParams(const std::vector<int> &numElements,
@@ -695,105 +768,127 @@ static ExtrudeParams *getExtrudeParams(const std::vector<int> &numElements,
   return e;
 }
 
-int gmshModelGeoExtrude(const vector_pair &inDimTags,
-                        const double dx, const double dy, const double dz,
-                        vector_pair &outDimTags,
-                        const std::vector<int> &numElements,
-                        const std::vector<double> &heights, const bool recombine)
+GMSH_API gmshModelGeoExtrude(const vector_pair &inDimTags,
+                             const double dx, const double dy, const double dz,
+                             vector_pair &outDimTags,
+                             const std::vector<int> &numElements,
+                             const std::vector<double> &heights,
+                             const bool recombine)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   outDimTags.clear();
-  return !GModel::current()->getGEOInternals()->extrude
-    (inDimTags, dx, dy, dz, outDimTags,
-     getExtrudeParams(numElements, heights, recombine));
-}
-
-int gmshModelGeoRevolve(const vector_pair &inDimTags,
-                        const double x, const double y, const double z,
-                        const double ax, const double ay, const double az,
-                        const double angle, vector_pair &outDimTags,
-                        const std::vector<int> &numElements,
-                        const std::vector<double> &heights, const bool recombine)
-{
-  if(!isInitialized()) return -1;
+  if(GModel::current()->getGEOInternals()->extrude
+     (inDimTags, dx, dy, dz, outDimTags,
+      getExtrudeParams(numElements, heights, recombine)))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
+}
+
+GMSH_API gmshModelGeoRevolve(const vector_pair &inDimTags,
+                             const double x, const double y, const double z,
+                             const double ax, const double ay, const double az,
+                             const double angle, vector_pair &outDimTags,
+                             const std::vector<int> &numElements,
+                             const std::vector<double> &heights,
+                             const bool recombine)
+{
+  if(!isInitialized()) return GMSH_ERROR(-1);
   outDimTags.clear();
-  return !GModel::current()->getGEOInternals()->revolve
+  if(GModel::current()->getGEOInternals()->revolve
     (inDimTags, x, y, z, ax, ay, az, angle, outDimTags,
-     getExtrudeParams(numElements, heights, recombine));
+     getExtrudeParams(numElements, heights, recombine)))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoTwist(const vector_pair &inDimTags,
-                      const double x, const double y, const double z,
-                      const double dx, const double dy, const double dz,
-                      const double ax, const double ay, const double az,
-                      const double angle, vector_pair &outDimTags,
-                      const std::vector<int> &numElements,
-                      const std::vector<double> &heights, const bool recombine)
+GMSH_API gmshModelGeoTwist(const vector_pair &inDimTags,
+                           const double x, const double y, const double z,
+                           const double dx, const double dy, const double dz,
+                           const double ax, const double ay, const double az,
+                           const double angle, vector_pair &outDimTags,
+                           const std::vector<int> &numElements,
+                           const std::vector<double> &heights,
+                           const bool recombine)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   outDimTags.clear();
-  return !GModel::current()->getGEOInternals()->twist
+  if(GModel::current()->getGEOInternals()->twist
     (inDimTags, x, y, z, dx, dy, dz, ax, ay, az, angle, outDimTags,
-     getExtrudeParams(numElements, heights, recombine));
+     getExtrudeParams(numElements, heights, recombine)))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoTranslate(const vector_pair &dimTags, const double dx,
-                          const double dy, const double dz)
+GMSH_API gmshModelGeoTranslate(const vector_pair &dimTags, const double dx,
+                               const double dy, const double dz)
 {
-  if(!isInitialized()) return -1;
-  return !GModel::current()->getGEOInternals()->translate(dimTags, dx, dy, dz);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  if(GModel::current()->getGEOInternals()->translate(dimTags, dx, dy, dz))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoRotate(const vector_pair &dimTags, const double x, const double y,
-                       const double z, const double ax, const double ay, const double az,
-                       const double angle)
+GMSH_API gmshModelGeoRotate(const vector_pair &dimTags, const double x,
+                            const double y, const double z, const double ax,
+                            const double ay, const double az, const double angle)
 {
-  if(!isInitialized()) return -1;
-  return !GModel::current()->getGEOInternals()->rotate
-    (dimTags, x, y, z, ax, ay, az, angle);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  if(GModel::current()->getGEOInternals()->rotate
+     (dimTags, x, y, z, ax, ay, az, angle))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoDilate(const vector_pair &dimTags, const double x, const double y,
-                       const double z, const double a, const double b, const double c)
+GMSH_API gmshModelGeoDilate(const vector_pair &dimTags, const double x,
+                            const double y, const double z, const double a,
+                            const double b, const double c)
 {
-  if(!isInitialized()) return -1;
-  return !GModel::current()->getGEOInternals()->dilate
-    (dimTags, x, y, z, a, b, c);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  if(GModel::current()->getGEOInternals()->dilate
+     (dimTags, x, y, z, a, b, c))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoSymmetry(const vector_pair &dimTags,
-                         const double a, const double b, const double c, const double d)
+GMSH_API gmshModelGeoSymmetry(const vector_pair &dimTags, const double a,
+                              const double b, const double c, const double d)
 {
-  if(!isInitialized()) return -1;
-  return !GModel::current()->getGEOInternals()->symmetry
-    (dimTags, a, b, c, d);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  if(GModel::current()->getGEOInternals()->symmetry
+     (dimTags, a, b, c, d))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoCopy(const vector_pair &inDimTags, vector_pair &outDimTags)
+GMSH_API gmshModelGeoCopy(const vector_pair &inDimTags, vector_pair &outDimTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   outDimTags.clear();
-  return !GModel::current()->getGEOInternals()->copy(inDimTags, outDimTags);
+  if(GModel::current()->getGEOInternals()->copy(inDimTags, outDimTags))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoRemove(const vector_pair &dimTags, const bool recursive)
+GMSH_API gmshModelGeoRemove(const vector_pair &dimTags, const bool recursive)
 {
-  if(!isInitialized()) return -1;
-  return !GModel::current()->getGEOInternals()->remove(dimTags, recursive);
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  if(GModel::current()->getGEOInternals()->remove(dimTags, recursive))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelGeoRemoveAllDuplicates()
+GMSH_API gmshModelGeoRemoveAllDuplicates()
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GModel::current()->getGEOInternals()->removeAllDuplicates();
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelGeoSetTransfiniteLine(const int tag, const int nPoints,
-                                   const std::string &type,
-                                   const double coef)
+GMSH_API gmshModelGeoSetTransfiniteLine(const int tag, const int nPoints,
+                                        const std::string &type,
+                                        const double coef)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   int t =
     (type == "Progression" || type == "Power") ? 1 :
     (type == "Bump") ? 2 :
@@ -802,13 +897,14 @@ int gmshModelGeoSetTransfiniteLine(const int tag, const int nPoints,
   // in .geo file we use a negative tag to do this trick; it's a bad idea
   if(coef < 0) t = -t;
   GModel::current()->getGEOInternals()->setTransfiniteLine(tag, nPoints, t, c);
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelGeoSetTransfiniteSurface(const int tag, const std::string &arrangement,
-                                      const std::vector<int> &cornerTags)
+GMSH_API gmshModelGeoSetTransfiniteSurface(const int tag,
+                                           const std::string &arrangement,
+                                           const std::vector<int> &cornerTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   int t =
     (arrangement == "Right") ? 1 :
     (arrangement == "Left") ? -1 :
@@ -817,53 +913,54 @@ int gmshModelGeoSetTransfiniteSurface(const int tag, const std::string &arrangem
     (arrangement == "Alternate") ? 2 :
     -1;
   GModel::current()->getGEOInternals()->setTransfiniteSurface(tag, t, cornerTags);
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelGeoSetTransfiniteVolume(const int tag, const std::vector<int> &cornerTags)
+GMSH_API gmshModelGeoSetTransfiniteVolume(const int tag,
+                                          const std::vector<int> &cornerTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GModel::current()->getGEOInternals()->setTransfiniteVolume(tag, cornerTags);
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelGeoSetRecombine(const int dim, const int tag, const double angle)
+GMSH_API gmshModelGeoSetRecombine(const int dim, const int tag, const double angle)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GModel::current()->getGEOInternals()->setRecombine(dim, tag, angle);
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelGeoSetSmoothing(const int dim, const int tag, const int val)
+GMSH_API gmshModelGeoSetSmoothing(const int dim, const int tag, const int val)
 {
-  if(!isInitialized()) return -1;
-  if(dim != 2) return 1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
+  if(dim != 2) return GMSH_ERROR(1);
   GModel::current()->getGEOInternals()->setSmoothing(tag, val);
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelGeoSetReverseMesh(const int dim, const int tag, const bool val)
+GMSH_API gmshModelGeoSetReverseMesh(const int dim, const int tag, const bool val)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GModel::current()->getGEOInternals()->setReverseMesh(dim, tag, val);
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelGeoSetMeshSize(const vector_pair &dimTags, const double size)
+GMSH_API gmshModelGeoSetMeshSize(const vector_pair &dimTags, const double size)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   for(unsigned int i = 0; i < dimTags.size(); i++){
     int dim = dimTags[i].first, tag = dimTags[i].second;
     GModel::current()->getGEOInternals()->setMeshSize(dim, tag, size);
   }
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelGeoSynchronize()
+GMSH_API gmshModelGeoSynchronize()
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   GModel::current()->getGEOInternals()->synchronize(GModel::current());
-  return 0;
+  return GMSH_OK;
 }
 
 // gmshModelOcc
@@ -873,471 +970,601 @@ static void createOcc()
   if(!GModel::current()->getOCCInternals()) GModel::current()->createOCCInternals();
 }
 
-int gmshModelOccAddPoint(const int tag, const double x, const double y, const double z,
-                         int &outTag, const double meshSize)
+GMSH_API gmshModelOccAddPoint(const int tag, const double x, const double y,
+                              const double z, const double meshSize)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addVertex(outTag, x, y, z, meshSize);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addVertex(outTag, x, y, z, meshSize)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddLine(const int tag, const int startTag, const int endTag,
-                        int &outTag)
+GMSH_API gmshModelOccAddLine(const int tag, const int startTag, const int endTag)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addLine(outTag, startTag, endTag);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addLine(outTag, startTag, endTag)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddCircleArc(const int tag, const int startTag, const int centerTag,
-                             const int endTag, int &outTag)
+GMSH_API gmshModelOccAddCircleArc(const int tag, const int startTag,
+                                  const int centerTag, const int endTag)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addCircleArc
-    (outTag, startTag, centerTag, endTag);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addCircleArc
+     (outTag, startTag, centerTag, endTag)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddCircle(const int tag, const double x, const double y, const double z,
-                          const double r, int &outTag, const double angle1,
-                          const double angle2)
+GMSH_API gmshModelOccAddCircle(const int tag, const double x, const double y,
+                               const double z, const double r, const double angle1,
+                               const double angle2)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addCircle
-    (outTag, x, y, z, r, angle1, angle2);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addCircle
+     (outTag, x, y, z, r, angle1, angle2)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddEllipseArc(const int tag, const int startTag, const int centerTag,
-                              const int endTag, int &outTag)
+GMSH_API gmshModelOccAddEllipseArc(const int tag, const int startTag,
+                                   const int centerTag, const int endTag)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addEllipseArc
-    (outTag, startTag, centerTag, endTag);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addEllipseArc
+     (outTag, startTag, centerTag, endTag)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddEllipse(const int tag, const double x, const double y, const double z,
-                           const double r1, const double r2, int &outTag,
-                           const double angle1, const double angle2)
+GMSH_API gmshModelOccAddEllipse(const int tag, const double x, const double y,
+                                const double z, const double r1, const double r2,
+                                const double angle1, const double angle2)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addEllipse
-    (outTag, x, y, z, r1, r2, angle1, angle2);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addEllipse
+     (outTag, x, y, z, r1, r2, angle1, angle2)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddSpline(const int tag, const std::vector<int> &vertexTags,
-                          int &outTag)
+GMSH_API gmshModelOccAddSpline(const int tag, const std::vector<int> &vertexTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addSpline(outTag, vertexTags);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addSpline(outTag, vertexTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddBezier(const int tag, const std::vector<int> &vertexTags,
-                          int &outTag)
+GMSH_API gmshModelOccAddBezier(const int tag, const std::vector<int> &vertexTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addBezier(outTag, vertexTags);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addBezier(outTag, vertexTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddBSpline(const int tag, const std::vector<int> &vertexTags,
-                           int &outTag)
+GMSH_API gmshModelOccAddBSpline(const int tag, const std::vector<int> &vertexTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addBSpline(outTag, vertexTags);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addBSpline(outTag, vertexTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddWire(const int tag, const std::vector<int> &edgeTags,
-                        int &outTag, const bool checkClosed)
+GMSH_API gmshModelOccAddWire(const int tag, const std::vector<int> &edgeTags,
+                             const bool checkClosed)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addWire
-    (outTag, edgeTags, checkClosed);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addWire
+     (outTag, edgeTags, checkClosed)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddLineLoop(const int tag, const std::vector<int> &edgeTags,
-                            int &outTag)
+GMSH_API gmshModelOccAddLineLoop(const int tag, const std::vector<int> &edgeTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addLineLoop(outTag, edgeTags);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addLineLoop(outTag, edgeTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddRectangle(const int tag, const double x, const double y,
-                             const double z, const double dx, const double dy,
-                             int &outTag, const double roundedRadius)
+GMSH_API gmshModelOccAddRectangle(const int tag, const double x, const double y,
+                                  const double z, const double dx, const double dy,
+                                  const double roundedRadius)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addRectangle
-    (outTag, x, y, z, dx, dy, roundedRadius);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addRectangle
+     (outTag, x, y, z, dx, dy, roundedRadius)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddDisk(const int tag, const double xc, const double yc,
-                        const double zc, const double rx, const double ry,
-                        int &outTag)
+GMSH_API gmshModelOccAddDisk(const int tag, const double xc, const double yc,
+                             const double zc, const double rx, const double ry)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addDisk
-    (outTag, xc, yc, zc, rx, ry);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addDisk
+     (outTag, xc, yc, zc, rx, ry)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddPlaneSurface(const int tag, const std::vector<int> &wireTags,
-                                int &outTag)
+GMSH_API gmshModelOccAddPlaneSurface(const int tag, const std::vector<int> &wireTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addPlaneSurface(outTag, wireTags);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addPlaneSurface(outTag, wireTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddSurfaceFilling(const int tag, const int wireTag, int &outTag)
+GMSH_API gmshModelOccAddSurfaceFilling(const int tag, const int wireTag)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addSurfaceFilling(outTag, wireTag);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addSurfaceFilling(outTag, wireTag)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddSurfaceLoop(const int tag, const std::vector<int> &faceTags,
-                               int &outTag)
+GMSH_API gmshModelOccAddSurfaceLoop(const int tag, const std::vector<int> &faceTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addSurfaceLoop(outTag, faceTags);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addSurfaceLoop(outTag, faceTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddVolume(const int tag, const std::vector<int> &shellTags,
-                          int &outTag)
+GMSH_API gmshModelOccAddVolume(const int tag, const std::vector<int> &shellTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addVolume(outTag, shellTags);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addVolume(outTag, shellTags)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddSphere(const int tag, const double xc, const double yc,
-                          const double zc, const double radius, int &outTag,
-                          const double angle1, const double angle2,
-                          const double angle3)
+GMSH_API gmshModelOccAddSphere(const int tag, const double xc, const double yc,
+                               const double zc, const double radius,
+                               const double angle1, const double angle2,
+                               const double angle3)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addSphere
-    (outTag, xc, yc, zc, radius, angle1, angle2, angle3);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addSphere
+     (outTag, xc, yc, zc, radius, angle1, angle2, angle3)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddBox(const int tag, const double x, const double y, const double z,
-                       const double dx, const double dy, const double dz, int &outTag)
+GMSH_API gmshModelOccAddBox(const int tag, const double x, const double y,
+                            const double z, const double dx, const double dy,
+                            const double dz)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addBox
-    (outTag, x, y, z, dx, dy, dz);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addBox
+     (outTag, x, y, z, dx, dy, dz)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddCylinder(const int tag, const double x, const double y,
-                            const double z, const double dx, const double dy,
-                            const double dz, const double r, int &outTag,
-                            const double angle)
+GMSH_API gmshModelOccAddCylinder(const int tag, const double x, const double y,
+                                 const double z, const double dx, const double dy,
+                                 const double dz, const double r, const double angle)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addCylinder
-    (outTag, x, y, z, dx, dy, dz, r, angle);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addCylinder
+     (outTag, x, y, z, dx, dy, dz, r, angle)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddCone(const int tag, const double x, const double y, const double z,
-                        const double dx, const double dy, const double dz,
-                        const double r1, const double r2, int &outTag,
-                        const double angle)
+GMSH_API gmshModelOccAddCone(const int tag, const double x, const double y,
+                             const double z, const double dx, const double dy,
+                             const double dz, const double r1, const double r2,
+                             const double angle)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addCone
-    (outTag, x, y, z, dx, dy, dz, r1, r2, angle);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addCone
+     (outTag, x, y, z, dx, dy, dz, r1, r2, angle)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddWedge(const int tag, const double x, const double y, const double z,
-                         const double dx, const double dy, const double dz,
-                         int &outTag, const double ltx)
+GMSH_API gmshModelOccAddWedge(const int tag, const double x, const double y,
+                              const double z, const double dx, const double dy,
+                              const double dz, const double ltx)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addWedge
-    (outTag, x, y, z, dx, dy, dz, ltx);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addWedge
+     (outTag, x, y, z, dx, dy, dz, ltx)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddTorus(const int tag, const double x, const double y, const double z,
-                         const double r1, const double r2, int &outTag,
-                         const double angle)
+GMSH_API gmshModelOccAddTorus(const int tag, const double x, const double y,
+                              const double z, const double r1, const double r2,
+                              const double angle)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  outTag = tag;
-  return !GModel::current()->getOCCInternals()->addTorus
-    (outTag, x, y, z, r1, r2, angle);
+  int outTag = tag;
+  if(GModel::current()->getOCCInternals()->addTorus
+     (outTag, x, y, z, r1, r2, angle)){
+    std::vector<int> ret(1, 0); ret.push_back(outTag);
+    return ret;
+  }
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddThruSections(const int tag, const std::vector<int> &wireTags,
-                                vector_pair &outDimTags, const bool makeSolid,
-                                const bool makeRuled)
+GMSH_API gmshModelOccAddThruSections(const int tag, const std::vector<int> &wireTags,
+                                     vector_pair &outDimTags, const bool makeSolid,
+                                     const bool makeRuled)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   outDimTags.clear();
-  return !GModel::current()->getOCCInternals()->addThruSections
-    (tag, wireTags, makeSolid, makeRuled, outDimTags);
+  if(GModel::current()->getOCCInternals()->addThruSections
+    (tag, wireTags, makeSolid, makeRuled, outDimTags))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
 GMSH_API addThickSolid(const int tag, const int solidTag,
                        const std::vector<int> &excludeFaceTags,
                        const double offset, vector_pair &outDimTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   outDimTags.clear();
-  return !GModel::current()->getOCCInternals()->addThickSolid
-    (tag, solidTag, excludeFaceTags, offset, outDimTags);
+  if(GModel::current()->getOCCInternals()->addThickSolid
+    (tag, solidTag, excludeFaceTags, offset, outDimTags))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccExtrude(const vector_pair &inDimTags,
-                        const double dx, const double dy, const double dz,
-                        vector_pair &outDimTags,
-                        const std::vector<int> &numElements,
-                        const std::vector<double> &heights, const bool recombine)
+GMSH_API gmshModelOccExtrude(const vector_pair &inDimTags,
+                             const double dx, const double dy, const double dz,
+                             vector_pair &outDimTags,
+                             const std::vector<int> &numElements,
+                             const std::vector<double> &heights,
+                             const bool recombine)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   outDimTags.clear();
-  return !GModel::current()->getOCCInternals()->extrude
+  if(GModel::current()->getOCCInternals()->extrude
     (inDimTags, dx, dy, dz, outDimTags,
-     getExtrudeParams(numElements, heights, recombine));
+     getExtrudeParams(numElements, heights, recombine)))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccRevolve(const vector_pair &inDimTags,
-                        const double x, const double y, const double z,
-                        const double ax, const double ay, const double az,
-                        const double angle, vector_pair &outDimTags,
-                        const std::vector<int> &numElements,
-                        const std::vector<double> &heights, const bool recombine)
+GMSH_API gmshModelOccRevolve(const vector_pair &inDimTags,
+                             const double x, const double y, const double z,
+                             const double ax, const double ay, const double az,
+                             const double angle, vector_pair &outDimTags,
+                             const std::vector<int> &numElements,
+                             const std::vector<double> &heights,
+                             const bool recombine)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   outDimTags.clear();
-  return !GModel::current()->getOCCInternals()->revolve
+  if(GModel::current()->getOCCInternals()->revolve
     (inDimTags, x, y, z, ax, ay, az, angle, outDimTags,
-     getExtrudeParams(numElements, heights, recombine));
+     getExtrudeParams(numElements, heights, recombine)))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccAddPipe(const vector_pair &inDimTags, const int wireTag,
-                        vector_pair &outDimTags)
+GMSH_API gmshModelOccAddPipe(const vector_pair &inDimTags, const int wireTag,
+                             vector_pair &outDimTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   outDimTags.clear();
-  return !GModel::current()->getOCCInternals()->addPipe
-    (inDimTags, wireTag, outDimTags);
+  if(GModel::current()->getOCCInternals()->addPipe
+    (inDimTags, wireTag, outDimTags))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccFillet(const std::vector<int> &regionTags,
-                       const std::vector<int> &edgeTags,
-                       const double radius, vector_pair &outDimTags,
-                       const bool removeRegion)
+GMSH_API gmshModelOccFillet(const std::vector<int> &regionTags,
+                            const std::vector<int> &edgeTags,
+                            const double radius, vector_pair &outDimTags,
+                            const bool removeRegion)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   outDimTags.clear();
-  return !GModel::current()->getOCCInternals()->fillet
-    (regionTags, edgeTags, radius, outDimTags, removeRegion);
+  if(GModel::current()->getOCCInternals()->fillet
+    (regionTags, edgeTags, radius, outDimTags, removeRegion))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccBooleanUnion(const int tag, const vector_pair &objectDimTags,
-                             const vector_pair &toolDimTags,
-                             vector_pair &outDimTags,
-                             std::vector<vector_pair > &outDimTagsMap,
-                             const bool removeObject, const bool removeTool)
+GMSH_API gmshModelOccBooleanUnion(const int tag,
+                                  const vector_pair &objectDimTags,
+                                  const vector_pair &toolDimTags,
+                                  vector_pair &outDimTags,
+                                  std::vector<vector_pair > &outDimTagsMap,
+                                  const bool removeObject,
+                                  const bool removeTool)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   outDimTags.clear();
   outDimTagsMap.clear();
-  return !GModel::current()->getOCCInternals()->booleanUnion
+  if(GModel::current()->getOCCInternals()->booleanUnion
     (tag, objectDimTags, toolDimTags, outDimTags, outDimTagsMap,
-     removeObject, removeTool);
+     removeObject, removeTool))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccBooleanIntersection(const int tag, const vector_pair &objectDimTags,
-                                    const vector_pair &toolDimTags,
-                                    vector_pair &outDimTags,
-                                    std::vector<vector_pair> &outDimTagsMap,
-                                    const bool removeObject, const bool removeTool)
+GMSH_API gmshModelOccBooleanIntersection(const int tag,
+                                         const vector_pair &objectDimTags,
+                                         const vector_pair &toolDimTags,
+                                         vector_pair &outDimTags,
+                                         std::vector<vector_pair> &outDimTagsMap,
+                                         const bool removeObject,
+                                         const bool removeTool)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   outDimTags.clear();
   outDimTagsMap.clear();
-  return !GModel::current()->getOCCInternals()->booleanIntersection
+  if(GModel::current()->getOCCInternals()->booleanIntersection
     (tag, objectDimTags, toolDimTags, outDimTags, outDimTagsMap,
-     removeObject, removeTool);
+     removeObject, removeTool))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccBooleanDifference(const int tag, const vector_pair &objectDimTags,
-                                  const vector_pair &toolDimTags,
-                                  vector_pair &outDimTags,
-                                  std::vector<vector_pair> &outDimTagsMap,
-                                  const bool removeObject, const bool removeTool)
+GMSH_API gmshModelOccBooleanDifference(const int tag,
+                                       const vector_pair &objectDimTags,
+                                       const vector_pair &toolDimTags,
+                                       vector_pair &outDimTags,
+                                       std::vector<vector_pair> &outDimTagsMap,
+                                       const bool removeObject,
+                                       const bool removeTool)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   outDimTags.clear();
   outDimTagsMap.clear();
-  return !GModel::current()->getOCCInternals()->booleanDifference
+  if(GModel::current()->getOCCInternals()->booleanDifference
     (tag, objectDimTags, toolDimTags, outDimTags, outDimTagsMap,
-     removeObject, removeTool);
+     removeObject, removeTool))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccBooleanFragments(const int tag, const vector_pair &objectDimTags,
-                                 const vector_pair &toolDimTags,
-                                 vector_pair &outDimTags,
-                                 std::vector<vector_pair> &outDimTagsMap,
-                                 const bool removeObject, const bool removeTool)
+GMSH_API gmshModelOccBooleanFragments(const int tag,
+                                      const vector_pair &objectDimTags,
+                                      const vector_pair &toolDimTags,
+                                      vector_pair &outDimTags,
+                                      std::vector<vector_pair> &outDimTagsMap,
+                                      const bool removeObject,
+                                      const bool removeTool)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   outDimTags.clear();
   outDimTagsMap.clear();
-  return !GModel::current()->getOCCInternals()->booleanFragments
+  if(GModel::current()->getOCCInternals()->booleanFragments
     (tag, objectDimTags, toolDimTags, outDimTags, outDimTagsMap,
-     removeObject, removeTool);
+     removeObject, removeTool))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccTranslate(const vector_pair &dimTags, const double dx,
-                          const double dy, const double dz)
+GMSH_API gmshModelOccTranslate(const vector_pair &dimTags, const double dx,
+                               const double dy, const double dz)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  return !GModel::current()->getOCCInternals()->translate(dimTags, dx, dy, dz);
+  if(GModel::current()->getOCCInternals()->translate(dimTags, dx, dy, dz))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccRotate(const vector_pair &dimTags, const double x, const double y,
-                       const double z, const double ax, const double ay, const double az,
-                       const double angle)
+GMSH_API gmshModelOccRotate(const vector_pair &dimTags, const double x,
+                            const double y, const double z, const double ax,
+                            const double ay, const double az, const double angle)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  return !GModel::current()->getOCCInternals()->rotate
-    (dimTags, x, y, z, ax, ay, az, angle);
+  if(GModel::current()->getOCCInternals()->rotate
+    (dimTags, x, y, z, ax, ay, az, angle))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccDilate(const vector_pair &dimTags, const double x, const double y,
-                       const double z, const double a, const double b, const double c)
+GMSH_API gmshModelOccDilate(const vector_pair &dimTags, const double x,
+                            const double y, const double z, const double a,
+                            const double b, const double c)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  return !GModel::current()->getOCCInternals()->dilate
-    (dimTags, x, y, z, a, b, c);
+  if(GModel::current()->getOCCInternals()->dilate
+    (dimTags, x, y, z, a, b, c))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccSymmetry(const vector_pair &dimTags,
-                         const double a, const double b, const double c, const double d)
+GMSH_API gmshModelOccSymmetry(const vector_pair &dimTags, const double a,
+                              const double b, const double c, const double d)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  return !GModel::current()->getOCCInternals()->symmetry
-    (dimTags, a, b, c, d);
+  if(GModel::current()->getOCCInternals()->symmetry
+    (dimTags, a, b, c, d))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccCopy(const vector_pair &inDimTags, vector_pair &outDimTags)
+GMSH_API gmshModelOccCopy(const vector_pair &inDimTags, vector_pair &outDimTags)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   outDimTags.clear();
-  return !GModel::current()->getOCCInternals()->copy(inDimTags, outDimTags);
+  if(GModel::current()->getOCCInternals()->copy(inDimTags, outDimTags))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccRemove(const vector_pair &dimTags, const bool recursive)
+GMSH_API gmshModelOccRemove(const vector_pair &dimTags, const bool recursive)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
-  return !GModel::current()->getOCCInternals()->remove(dimTags, recursive);
+  if(GModel::current()->getOCCInternals()->remove(dimTags, recursive))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccRemoveAllDuplicates()
+GMSH_API gmshModelOccRemoveAllDuplicates()
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   GModel::current()->getOCCInternals()->removeAllDuplicates();
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelOccImportShapes(const std::string &fileName, vector_pair &outDimTags,
-                             const bool highestDimOnly, const std::string &format)
+GMSH_API gmshModelOccImportShapes(const std::string &fileName,
+                                  vector_pair &outDimTags,
+                                  const bool highestDimOnly,
+                                  const std::string &format)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   outDimTags.clear();
-  return !GModel::current()->getOCCInternals()->importShapes
-    (fileName, highestDimOnly, outDimTags, format);
+  if(GModel::current()->getOCCInternals()->importShapes
+    (fileName, highestDimOnly, outDimTags, format))
+    return GMSH_OK;
+  return GMSH_ERROR(1);
 }
 
-int gmshModelOccSetMeshSize(const vector_pair &dimTags, const double size)
+GMSH_API gmshModelOccSetMeshSize(const vector_pair &dimTags, const double size)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   for(unsigned int i = 0; i < dimTags.size(); i++){
     int dim = dimTags[i].first, tag = dimTags[i].second;
     GModel::current()->getOCCInternals()->setMeshSize(dim, tag, size);
   }
-  return 0;
+  return GMSH_OK;
 }
 
-int gmshModelOccSynchronize()
+GMSH_API gmshModelOccSynchronize()
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
   createOcc();
   GModel::current()->getOCCInternals()->synchronize(GModel::current());
-  return 0;
+  return GMSH_OK;
 }
 
 // gmshModelField
 
-int gmshModelFieldCreate(const int tag, const std::string &type)
+GMSH_API gmshModelFieldCreate(const int tag, const std::string &type)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
 #if defined(HAVE_MESH)
   if(!GModel::current()->getFields()->newField(tag, type)){
     Msg::Error("Cannot create Field %i of type '%s'", tag, type.c_str());
-    return 1;
+    return GMSH_ERROR(1);
   }
-  return 0;
+  return GMSH_OK;
 #else
-  return 1;
+  return GMSH_ERROR(1);
 #endif
 }
 
@@ -1359,51 +1586,51 @@ static FieldOption *getFieldOption(const int tag, const std::string &option)
 }
 #endif
 
-int gmshModelFieldSetNumber(const int tag, const std::string &option,
-                            const double value)
+GMSH_API gmshModelFieldSetNumber(const int tag, const std::string &option,
+                                 const double value)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
 #if defined(HAVE_MESH)
   FieldOption *o = getFieldOption(tag, option);
-  if(!o) return 1;
+  if(!o) return GMSH_ERROR(1);
   try { o->numericalValue(value); }
   catch(...){
     Msg::Error("Cannot set numerical value to option '%s' in field %i",
                option.c_str(), tag);
-    return 1;
+    return GMSH_ERROR(1);
   }
-  return 0;
+  return GMSH_OK;
 #else
-  return 1;
+  return GMSH_ERROR(1);
 #endif
 }
 
-int gmshModelFieldSetString(const int tag, const std::string &option,
-                            const std::string &value)
+GMSH_API gmshModelFieldSetString(const int tag, const std::string &option,
+                                 const std::string &value)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
 #if defined(HAVE_MESH)
   FieldOption *o = getFieldOption(tag, option);
-  if(!o) return 1;
+  if(!o) return GMSH_ERROR(1);
   try { o->string(value); }
   catch(...){
     Msg::Error("Cannot set string value to option '%s' in field %i",
                option.c_str(), tag);
-    return 1;
+    return GMSH_ERROR(1);
   }
-  return 0;
+  return GMSH_OK;
 #else
-  return 1;
+  return GMSH_ERROR(1);
 #endif
 }
 
-int gmshModelFieldSetNumbers(const int tag, const std::string &option,
-                             const std::vector<double> &value)
+GMSH_API gmshModelFieldSetNumbers(const int tag, const std::string &option,
+                                  const std::vector<double> &value)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
 #if defined(HAVE_MESH)
   FieldOption *o = getFieldOption(tag, option);
-  if(!o) return 1;
+  if(!o) return GMSH_ERROR(1);
   try {
     if(o->getType() == FIELD_OPTION_LIST) {
       std::list<int> vl;
@@ -1421,32 +1648,32 @@ int gmshModelFieldSetNumbers(const int tag, const std::string &option,
   catch(...){
     Msg::Error("Cannot set numeric values to option '%s' in field %i",
                option.c_str(), tag);
-    return 1;
+    return GMSH_ERROR(1);
   }
-  return 0;
+  return GMSH_OK;
 #else
-  return 1;
+  return GMSH_ERROR(1);
 #endif
 }
 
-int gmshModelFieldSetAsBackground(const int tag)
+GMSH_API gmshModelFieldSetAsBackground(const int tag)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
 #if defined(HAVE_MESH)
   GModel::current()->getFields()->setBackgroundFieldId(tag);
-  return 0;
+  return GMSH_OK;
 #else
-  return 1;
+  return GMSH_ERROR(1);
 #endif
 }
 
-int gmshModelFieldDelete(const int tag)
+GMSH_API gmshModelFieldDelete(const int tag)
 {
-  if(!isInitialized()) return -1;
+  if(!isInitialized()) return GMSH_ERROR(-1);
 #if defined(HAVE_MESH)
   GModel::current()->getFields()->deleteField(tag);
-  return 0;
+  return GMSH_OK;
 #else
-  return 1;
+  return GMSH_ERROR(1);
 #endif
 }
diff --git a/Common/gmsh.h b/Common/gmsh.h
index 2995045395f52ae7d000ba13233c3a9462a9cff7..3a05835b225d781c0fca27d8b7a13a8949a90a20 100644
--- a/Common/gmsh.h
+++ b/Common/gmsh.h
@@ -17,16 +17,18 @@
 // By design, the API is purely functional, and only uses elementary C++ types
 // from the standard library. This design should not and will not change.
 
-// All functions return 0 on successful completion.
+// All functions return 0 as the first entry of the returned vector on
+// successful completion. Additional integer results can be appends to this
+// returned value, depending on context.
 
 #include <cmath>
 #include <vector>
 #include <string>
 
 #if defined(WIN32)
-#define GMSH_API __declspec(dllexport) int
+#define GMSH_API __declspec(dllexport) std::vector<int>
 #else
-#define GMSH_API int
+#define GMSH_API std::vector<int>
 #endif
 
 typedef std::vector<std::pair<int, int> > vector_pair;
@@ -57,8 +59,10 @@ GMSH_API gmshModelGetEntitiesForPhysicalGroup(const int dim, const int tag,
                                               std::vector<int> &tags);
 GMSH_API gmshModelSetPhysicalName(const int dim, const int tag,
                                   const std::string &name);
-GMSH_API gmshModelGetPhysicalName(const int dim, const int tag, std::string &name);
-GMSH_API gmshModelGetVertexCoordinates(const int tag, double &x, double &y, double &z);
+GMSH_API gmshModelGetPhysicalName(const int dim, const int tag,
+                                  std::string &name);
+GMSH_API gmshModelGetVertexCoordinates(const int tag, double &x, double &y,
+                                       double &z);
 GMSH_API gmshModelGetBoundary(const vector_pair &inDimTags, vector_pair &outDimTags,
                               const bool combined = true, const bool oriented = true,
                               const bool recursive = false);
@@ -96,32 +100,25 @@ GMSH_API gmshModelEmbed(const int dim, const std::vector<int> &tags, const int i
 
 // gmshModelGeo
 GMSH_API gmshModelGeoAddPoint(const int tag, const double x, const double y,
-                              const double z, int &outTag, const double meshSize = 0.);
-GMSH_API gmshModelGeoAddLine(const int tag, const int startTag, const int endTag,
-                             int &outTag);
-GMSH_API gmshModelGeoAddCircleArc(const int tag, const int startTag, const int centerTag,
-                                  const int endTag, int &outTag, const double nx = 0.,
-                                  const double ny = 0., const double nz = 0.);
+                              const double z, const double meshSize = 0.);
+GMSH_API gmshModelGeoAddLine(const int tag, const int startTag, const int endTag);
+GMSH_API gmshModelGeoAddCircleArc(const int tag, const int startTag,
+                                  const int centerTag, const int endTag,
+                                  const double nx = 0., const double ny = 0.,
+                                  const double nz = 0.);
 GMSH_API gmshModelGeoAddEllipseArc(const int tag, const int startTag, const int centerTag,
-                                   const int majorTag, const int endTag, int &outTag,
+                                   const int majorTag, const int endTag,
                                    const double nx = 0., const double ny = 0.,
                                    const double nz = 0.);
-GMSH_API gmshModelGeoAddSpline(const int tag, const std::vector<int> &vertexTags,
-                               int &outTag);
-GMSH_API gmshModelGeoAddBSpline(const int tag, const std::vector<int> &vertexTags,
-                                int &outTag);
-GMSH_API gmshModelGeoAddBezier(const int tag, const std::vector<int> &vertexTags,
-                               int &outTag);
-GMSH_API gmshModelGeoAddLineLoop(const int tag, const std::vector<int> &edgeTags,
-                                 int &outTag);
-GMSH_API gmshModelGeoAddPlaneSurface(const int tag, const std::vector<int> &wireTags,
-                                     int &outTag);
+GMSH_API gmshModelGeoAddSpline(const int tag, const std::vector<int> &vertexTags);
+GMSH_API gmshModelGeoAddBSpline(const int tag, const std::vector<int> &vertexTags);
+GMSH_API gmshModelGeoAddBezier(const int tag, const std::vector<int> &vertexTags);
+GMSH_API gmshModelGeoAddLineLoop(const int tag, const std::vector<int> &edgeTags);
+GMSH_API gmshModelGeoAddPlaneSurface(const int tag, const std::vector<int> &wireTags);
 GMSH_API gmshModelGeoAddSurfaceFilling(const int tag, const std::vector<int> &wireTags,
-                                       int &outTag, const int sphereCenterTag = -1);
-GMSH_API gmshModelGeoAddSurfaceLoop(const int tag, const std::vector<int> &faceTags,
-                                    int &outTag);
-GMSH_API gmshModelGeoAddVolume(const int tag, const std::vector<int> &shellTags,
-                               int &outTag);
+                                       const int sphereCenterTag = -1);
+GMSH_API gmshModelGeoAddSurfaceLoop(const int tag, const std::vector<int> &faceTags);
+GMSH_API gmshModelGeoAddVolume(const int tag, const std::vector<int> &shellTags);
 GMSH_API gmshModelGeoExtrude(const vector_pair &inDimTags,
                              const double dx, const double dy, const double dz,
                              vector_pair &outDimTags,
@@ -176,65 +173,56 @@ GMSH_API gmshModelGeoSynchronize();
 
 // gmshModelOcc
 GMSH_API gmshModelOccAddPoint(const int tag, const double x, const double y,
-                              const double z, int &outTag, const double meshSize = 0.);
-GMSH_API gmshModelOccAddLine(const int tag, const int startTag, const int endTag,
-                             int &outTag);
+                              const double z, const double meshSize = 0.);
+GMSH_API gmshModelOccAddLine(const int tag, const int startTag, const int endTag);
 GMSH_API gmshModelOccAddCircleArc(const int tag, const int startTag, const int centerTag,
-                                  const int endTag, int &outTag);
+                                  const int endTag);
 GMSH_API gmshModelOccAddCircle(const int tag, const double x, const double y,
-                               const double z, const double r, int &outTag,
+                               const double z, const double r,
                                const double angle1 = 0., const double angle2 = 2*M_PI);
 GMSH_API gmshModelOccAddEllipseArc(const int tag, const int startTag, const int centerTag,
-                                   const int endTag, int &outTag);
+                                   const int endTag);
 GMSH_API gmshModelOccAddEllipse(const int tag, const double x, const double y,
                                 const double z, const double r1, const double r2,
-                                int &outTag, const double angle1 = 0.,
+                                const double angle1 = 0.,
                                 const double angle2 = 2*M_PI);
-GMSH_API gmshModelOccAddSpline(const int tag, const std::vector<int> &vertexTags,
-                               int &outTag);
-GMSH_API gmshModelOccAddBezier(const int tag, const std::vector<int> &vertexTags,
-                               int &outTag);
-GMSH_API gmshModelOccAddBSpline(const int tag, const std::vector<int> &vertexTags,
-                                int &outTag);
+GMSH_API gmshModelOccAddSpline(const int tag, const std::vector<int> &vertexTags);
+GMSH_API gmshModelOccAddBezier(const int tag, const std::vector<int> &vertexTags);
+GMSH_API gmshModelOccAddBSpline(const int tag, const std::vector<int> &vertexTags);
 GMSH_API gmshModelOccAddWire(const int tag, const std::vector<int> &edgeTags,
-                             int &outTag, const bool checkClosed = false);
-GMSH_API gmshModelOccAddLineLoop(const int tag, const std::vector<int> &edgeTags,
-                                 int &outTag);
+                             const bool checkClosed = false);
+GMSH_API gmshModelOccAddLineLoop(const int tag, const std::vector<int> &edgeTags);
 GMSH_API gmshModelOccAddRectangle(const int tag, const double x, const double y,
                                   const double z, const double dx, const double dy,
-                                  int &outTag, const double roundedRadius = 0.);
+                                  const double roundedRadius = 0.);
 GMSH_API gmshModelOccAddDisk(const int tag, const double xc, const double yc,
-                             const double zc, const double rx, const double ry,
-                             int &outTag);
-GMSH_API gmshModelOccAddPlaneSurface(const int tag, const std::vector<int> &wireTags,
-                                     int &outTag);
-GMSH_API gmshModelOccAddSurfaceFilling(const int tag, int wireTag, int &outTag);
-GMSH_API gmshModelOccAddSurfaceLoop(const int tag, const std::vector<int> &faceTags,
-                                    int &outTag);
-GMSH_API gmshModelOccAddVolume(const int tag, const std::vector<int> &shellTags,
-                               int &outTag);
+                             const double zc, const double rx, const double ry);
+GMSH_API gmshModelOccAddPlaneSurface(const int tag, const std::vector<int> &wireTags);
+GMSH_API gmshModelOccAddSurfaceFilling(const int tag, int wireTag);
+GMSH_API gmshModelOccAddSurfaceLoop(const int tag, const std::vector<int> &faceTags);
+GMSH_API gmshModelOccAddVolume(const int tag, const std::vector<int> &shellTags);
 GMSH_API gmshModelOccAddSphere(const int tag, const double xc, const double yc,
-                               const double zc, const double radius, int &outTag,
+                               const double zc, const double radius,
                                const double angle1 = -M_PI/2,
                                const double angle2 = M_PI/2,
                                const double angle3 = 2*M_PI);
 GMSH_API gmshModelOccAddBox(const int tag, const double x, const double y,
                             const double z, const double dx, const double dy,
-                            const double dz, int &outTag);
+                            const double dz);
 GMSH_API gmshModelOccAddCylinder(const int tag, const double x, const double y,
                                  const double z, const double dx, const double dy,
-                                 const double dz, const double r, int &outTag,
+                                 const double dz, const double r,
                                  double angle = 2*M_PI);
 GMSH_API gmshModelOccAddCone(const int tag, const double x, const double y,
                              const double z, const double dx, const double dy,
                              const double dz, const double r1, const double r2,
-                             int &outTag, const double angle = 2*M_PI);
+                             const double angle = 2*M_PI);
 GMSH_API gmshModelOccAddWedge(const int tag, const double x, const double y,
                               const double z, const double dx, const double dy,
-                              const double dz, int &outTag, const double ltx = 0.);
+                              const double dz, const double ltx = 0.);
 GMSH_API gmshModelOccAddTorus(const int tag, const double x, const double y,
                               const double z, const double r1, const double r2,
-                              int &outTag, const double angle = 2*M_PI);
+                              const double angle = 2*M_PI);
 GMSH_API gmshModelOccAddThruSections(const int tag, const std::vector<int> &wireTags,
                                      vector_pair &outDimTags, const bool makeSolid = true,
                                      const bool makeRuled = false);
@@ -320,4 +308,6 @@ GMSH_API gmshModelFieldDelete(const int tag);
 
 // gmshGraphics
 
+#undef GMSH_API
+
 #endif
diff --git a/Common/gmsh.i b/Common/gmsh.i
index eb6be8270f6a6b23f3461c21dccc059b045a79f0..e74857288b0f40fdda50a027b0d202b65c39ac4d 100644
--- a/Common/gmsh.i
+++ b/Common/gmsh.i
@@ -1,10 +1,5 @@
 %module gmsh
 
-// "int &outTag" in function arguments is replaced by an append of outTag to the
-// value returned by the function
-%include typemaps.i
-%apply int &OUTPUT { int &outTag };
-
 // handle gracefully the arguments of gmshInitialize
 %include argcargv.i
 %apply (int ARGC, char **ARGV) { (int argc, char **argv) }
diff --git a/demos/api/boolean.cpp b/demos/api/boolean.cpp
index 1ca9de0118e6c1b37f950b1d7e92916c4691cf7d..0cb8a9f97ce5a9602ab16457b0c2b95ae28eaa83 100644
--- a/demos/api/boolean.cpp
+++ b/demos/api/boolean.cpp
@@ -17,15 +17,14 @@ int main(int argc, char **argv)
 
   double R = 1.4, Rs = R*.7, Rt = R*1.25;
 
-  int o;
   std::vector<std::pair<int, int> > ov;
   std::vector<std::vector<std::pair<int, int> > > ovv;
-  gmshModelOccAddBox(1, -R,-R,-R, 2*R,2*R,2*R, o);
-  gmshModelOccAddSphere(2, 0,0,0,Rt, o);
+  gmshModelOccAddBox(1, -R,-R,-R, 2*R,2*R,2*R);
+  gmshModelOccAddSphere(2, 0,0,0,Rt);
   gmshModelOccBooleanIntersection(3, {{3, 1}}, {{3, 2}}, ov, ovv);
-  gmshModelOccAddCylinder(4, -2*R,0,0, 4*R,0,0, Rs, o);
-  gmshModelOccAddCylinder(5, 0,-2*R,0, 0,4*R,0, Rs, o);
-  gmshModelOccAddCylinder(6, 0,0,-2*R, 0,0,4*R, Rs, o);
+  gmshModelOccAddCylinder(4, -2*R,0,0, 4*R,0,0, Rs);
+  gmshModelOccAddCylinder(5, 0,-2*R,0, 0,4*R,0, Rs);
+  gmshModelOccAddCylinder(6, 0,0,-2*R, 0,0,4*R, Rs);
   gmshModelOccBooleanUnion(7, {{3, 4}, {3, 5}}, {{3, 6}}, ov, ovv);
   gmshModelOccBooleanDifference(8, {{3, 3}}, {{3, 7}}, ov, ovv);
 
diff --git a/demos/api/t1.cpp b/demos/api/t1.cpp
index c2d08070956c93f2e7706b0dabc3f91feec4058b..522b7ee2f45081b70e78dec6c8569ab8616f93fd 100644
--- a/demos/api/t1.cpp
+++ b/demos/api/t1.cpp
@@ -9,7 +9,9 @@
 int main(int argc, char **argv)
 {
   // Before using any functions in the C++ API, Gmsh must be initialized. All
-  // the function in the API return 0 on successful completion.
+  // the functions in the API return a vector of integers. The first integer is
+  // 0 on successful completion; additional integers can be appended depending
+  // on context.
   gmshInitialize();
 
   // By default Gmsh will not print out any messages: in order to output
@@ -27,35 +29,28 @@ int main(int argc, char **argv)
   // have the "gmshModeGeo" prefix. To create geometrical points with the
   // built-in CAD kernel, one thus uses gmshModelGeoAddPoint():
   //
-  // - the first argument is the point tag ; if positive, the point is created
-  //   with this tag ; if negative, a new (unused) tag will be assigned and
-  //   returned (in the 5th argument)
+  // - the first argument is the point tag
   //
   // - the next 3 arguments are the point coordinates (x, y, z)
   //
-  // - the fifth argument is the actual id of the point: equal to tag if tag >
-  //   0, or a new one if tag < 0
-  //
   // - the last (optional) argument is the target mesh size close to the point
   double lc = 1e-2;
-  int o;
-  gmshModelGeoAddPoint(1, 0, 0, 0, o, lc);
-  gmshModelGeoAddPoint(2, .1, 0,  0, o, lc);
-  gmshModelGeoAddPoint(3, .1, .3, 0, o, lc);
-  gmshModelGeoAddPoint(4, 0,  .3, 0, o, lc);
+  gmshModelGeoAddPoint(1, 0, 0, 0, lc);
+  gmshModelGeoAddPoint(2, .1, 0,  0, lc);
+  gmshModelGeoAddPoint(3, .1, .3, 0, lc);
+  gmshModelGeoAddPoint(4, 0,  .3, 0, lc);
 
   // The API to create lines with the built-in kernel follows the same
-  // conventions: the first argument is a tag (here positive to force it),
-  // followed by 2 point tags, followed by the actual (returned) tag.
-  gmshModelGeoAddLine(1, 1, 2, o);
-  gmshModelGeoAddLine(2, 3, 2, o);
-  gmshModelGeoAddLine(3, 3, 4, o);
-  gmshModelGeoAddLine(4, 4, 1, o);
+  // conventions: the first argument is the line tag, followed by 2 point tags.
+  gmshModelGeoAddLine(1, 1, 2);
+  gmshModelGeoAddLine(2, 3, 2);
+  gmshModelGeoAddLine(3, 3, 4);
+  gmshModelGeoAddLine(4, 4, 1);
 
   // The philosophy to construct line loops and surfaces is similar: the second
   // arguments are now vectors of integers.
-  gmshModelGeoAddLineLoop(1, {4, 1, -2, 3}, o);
-  gmshModelGeoAddPlaneSurface(1, {1}, o);
+  gmshModelGeoAddLineLoop(1, {4, 1, -2, 3});
+  gmshModelGeoAddPlaneSurface(1, {1});
 
   // Physical groups are defined by providing the dimension of the group (0 for
   // physical points, 1 for physical lines, 2 for physical surfaces and 3 for
diff --git a/demos/api/t10.cpp b/demos/api/t10.cpp
index 183fa16441e219f1a71a57fa5833715f461729b9..dfe51c67cdc77e0fa08982d33b343bf486aa04a8 100644
--- a/demos/api/t10.cpp
+++ b/demos/api/t10.cpp
@@ -10,21 +10,20 @@ int main(int argc, char **argv)
 
   gmshModelCreate("t1");
 
-  int o;
   double lc = .15;
-  gmshModelGeoAddPoint(1, 0.0,0.0,0, o,lc);
-  gmshModelGeoAddPoint(2, 1,0.0,0, o,lc);
-  gmshModelGeoAddPoint(3, 1,1,0, o,lc);
-  gmshModelGeoAddPoint(4, 0,1,0, o,lc);
-  gmshModelGeoAddPoint(5, 0.2,.5,0, o,lc);
+  gmshModelGeoAddPoint(1, 0.0,0.0,0,lc);
+  gmshModelGeoAddPoint(2, 1,0.0,0,lc);
+  gmshModelGeoAddPoint(3, 1,1,0,lc);
+  gmshModelGeoAddPoint(4, 0,1,0,lc);
+  gmshModelGeoAddPoint(5, 0.2,.5,0,lc);
 
-  gmshModelGeoAddLine(1, 1,2, o);
-  gmshModelGeoAddLine(2, 2,3, o);
-  gmshModelGeoAddLine(3, 3,4, o);
-  gmshModelGeoAddLine(4, 4,1, o);
+  gmshModelGeoAddLine(1, 1,2);
+  gmshModelGeoAddLine(2, 2,3);
+  gmshModelGeoAddLine(3, 3,4);
+  gmshModelGeoAddLine(4, 4,1);
 
-  gmshModelGeoAddLineLoop(5, {1,2,3,4}, o);
-  gmshModelGeoAddPlaneSurface(6, {5}, o);
+  gmshModelGeoAddLineLoop(5, {1,2,3,4});
+  gmshModelGeoAddPlaneSurface(6, {5});
 
   gmshModelFieldCreate(1, "Attractor");
   gmshModelFieldSetNumbers(1, "NodesList", {5});
diff --git a/demos/api/t16.cpp b/demos/api/t16.cpp
index fbba8f9a7060ed7690c996b00dc213c588ed4c60..65d38a899999fa7a8c13fa03a388b1fe74498018 100644
--- a/demos/api/t16.cpp
+++ b/demos/api/t16.cpp
@@ -9,18 +9,17 @@ int main(int argc, char **argv)
 
   gmshModelCreate("t16");
 
-  int o;
   std::vector<std::pair<int, int> > ov;
   std::vector<std::vector<std::pair<int, int> > > ovv;
-  gmshModelOccAddBox(1, 0,0,0, 1,1,1, o);
-  gmshModelOccAddBox(2, 0,0,0, 0.5,0.5,0.5, o);
+  gmshModelOccAddBox(1, 0,0,0, 1,1,1);
+  gmshModelOccAddBox(2, 0,0,0, 0.5,0.5,0.5);
   gmshModelOccBooleanDifference(3, {{3,1}}, {{3,2}}, ov, ovv);
   double x = 0, y = 0.75, z = 0, r = 0.09 ;
   std::vector<std::pair<int, int> > holes;
   for(int t = 1; t <= 5; t++){
     x += 0.166 ;
     z += 0.166 ;
-    gmshModelOccAddSphere(3 + t, x,y,z,r, o);
+    gmshModelOccAddSphere(3 + t, x,y,z,r);
     holes.push_back({3, 3 + t});
   }
   gmshModelOccBooleanFragments(-1, {{3,3}}, holes, ov, ovv);
diff --git a/demos/api/t2.cpp b/demos/api/t2.cpp
index be48cd38cc82bbcaddf9d388ae4ce3561c6c520e..b60e48a6cac0fdae6ff36dca1eae262a52dde482 100644
--- a/demos/api/t2.cpp
+++ b/demos/api/t2.cpp
@@ -14,27 +14,26 @@ int main(int argc, char **argv)
 
   // Copied from t1.cpp...
   double lc = 1e-2;
-  int o;
-  gmshModelGeoAddPoint(1, 0, 0, 0, o, lc);
-  gmshModelGeoAddPoint(2, .1, 0,  0, o, lc);
-  gmshModelGeoAddPoint(3, .1, .3, 0, o, lc);
-  gmshModelGeoAddPoint(4, 0,  .3, 0, o, lc);
-
-  gmshModelGeoAddLine(1, 1, 2, o);
-  gmshModelGeoAddLine(2, 3, 2, o);
-  gmshModelGeoAddLine(3, 3, 4, o);
-  gmshModelGeoAddLine(4, 4, 1, o);
-
-  gmshModelGeoAddLineLoop(1, {4, 1, -2, 3}, o);
-  gmshModelGeoAddPlaneSurface(1, {1}, o);
+  gmshModelGeoAddPoint(1, 0, 0, 0, lc);
+  gmshModelGeoAddPoint(2, .1, 0,  0, lc);
+  gmshModelGeoAddPoint(3, .1, .3, 0, lc);
+  gmshModelGeoAddPoint(4, 0,  .3, 0, lc);
+
+  gmshModelGeoAddLine(1, 1, 2);
+  gmshModelGeoAddLine(2, 3, 2);
+  gmshModelGeoAddLine(3, 3, 4);
+  gmshModelGeoAddLine(4, 4, 1);
+
+  gmshModelGeoAddLineLoop(1, {4, 1, -2, 3});
+  gmshModelGeoAddPlaneSurface(1, {1});
   gmshModelAddPhysicalGroup(0, 1, {1, 2});
   gmshModelAddPhysicalGroup(1, 2, {1, 2});
   gmshModelAddPhysicalGroup(2, 6, {1});
   gmshModelSetPhysicalName(2, 6, "My surface");
   // ...end of copy
 
-  gmshModelGeoAddPoint(5, 0, .4, 0, o, lc);
-  gmshModelGeoAddLine(5, 4, 5, o);
+  gmshModelGeoAddPoint(5, 0, .4, 0, lc);
+  gmshModelGeoAddLine(5, 4, 5);
 
   // Geometrical transformations take a vector of pairs of integers as first
   // argument, which contains the list of entities, represented by (dimension,
@@ -49,45 +48,45 @@ int main(int argc, char **argv)
   gmshModelGeoCopy({{0, 3}}, ov);
   gmshModelGeoTranslate(ov, 0, 0.1, 0);
 
-  gmshModelGeoAddLine(7, 3, ov[0].second, o);
-  gmshModelGeoAddLine(8, ov[0].second, 5, o);
-  gmshModelGeoAddLineLoop(10, {5,-8,-7,3}, o);
-  gmshModelGeoAddPlaneSurface(11, {10}, o);
+  gmshModelGeoAddLine(7, 3, ov[0].second);
+  gmshModelGeoAddLine(8, ov[0].second, 5);
+  gmshModelGeoAddLineLoop(10, {5,-8,-7,3});
+  gmshModelGeoAddPlaneSurface(11, {10});
 
   gmshModelGeoCopy({{2, 1}, {2, 11}}, ov);
   gmshModelGeoTranslate(ov, 0.12, 0, 0);
 
   std::printf("New surfaces '%d' and '%d'\n", ov[0].second, ov[1].second);
 
-  gmshModelGeoAddPoint(100, 0., 0.3, 0.13, o, lc);
-  gmshModelGeoAddPoint(101, 0.08, 0.3, 0.1, o, lc);
-  gmshModelGeoAddPoint(102, 0.08, 0.4, 0.1, o, lc);
-  gmshModelGeoAddPoint(103, 0., 0.4, 0.13, o, lc);
-
-  gmshModelGeoAddLine(110, 4, 100, o);
-  gmshModelGeoAddLine(111, 3, 101, o);
-  gmshModelGeoAddLine(112, 6, 102, o);
-  gmshModelGeoAddLine(113, 5, 103, o);
-  gmshModelGeoAddLine(114, 103, 100, o);
-  gmshModelGeoAddLine(115, 100, 101, o);
-  gmshModelGeoAddLine(116, 101, 102, o);
-  gmshModelGeoAddLine(117, 102, 103, o);
-
-  gmshModelGeoAddLineLoop(118, {115, -111, 3, 110}, o);
-  gmshModelGeoAddPlaneSurface(119, {118}, o);
-  gmshModelGeoAddLineLoop(120, {111, 116, -112, -7}, o);
-  gmshModelGeoAddPlaneSurface(121, {120}, o);
-  gmshModelGeoAddLineLoop(122, {112, 117, -113, -8}, o);
-  gmshModelGeoAddPlaneSurface(123, {122}, o);
-  gmshModelGeoAddLineLoop(124, {114, -110, 5, 113}, o);
-  gmshModelGeoAddPlaneSurface(125, {124}, o);
-  gmshModelGeoAddLineLoop(126, {115, 116, 117, 114}, o);
-  gmshModelGeoAddPlaneSurface(127, {126}, o);
+  gmshModelGeoAddPoint(100, 0., 0.3, 0.13, lc);
+  gmshModelGeoAddPoint(101, 0.08, 0.3, 0.1, lc);
+  gmshModelGeoAddPoint(102, 0.08, 0.4, 0.1, lc);
+  gmshModelGeoAddPoint(103, 0., 0.4, 0.13, lc);
+
+  gmshModelGeoAddLine(110, 4, 100);
+  gmshModelGeoAddLine(111, 3, 101);
+  gmshModelGeoAddLine(112, 6, 102);
+  gmshModelGeoAddLine(113, 5, 103);
+  gmshModelGeoAddLine(114, 103, 100);
+  gmshModelGeoAddLine(115, 100, 101);
+  gmshModelGeoAddLine(116, 101, 102);
+  gmshModelGeoAddLine(117, 102, 103);
+
+  gmshModelGeoAddLineLoop(118, {115, -111, 3, 110});
+  gmshModelGeoAddPlaneSurface(119, {118});
+  gmshModelGeoAddLineLoop(120, {111, 116, -112, -7});
+  gmshModelGeoAddPlaneSurface(121, {120});
+  gmshModelGeoAddLineLoop(122, {112, 117, -113, -8});
+  gmshModelGeoAddPlaneSurface(123, {122});
+  gmshModelGeoAddLineLoop(124, {114, -110, 5, 113});
+  gmshModelGeoAddPlaneSurface(125, {124});
+  gmshModelGeoAddLineLoop(126, {115, 116, 117, 114});
+  gmshModelGeoAddPlaneSurface(127, {126});
 
   // The API to create surface loops ("shells") and volumes is similar to the
   // one used to create line loops and surfaces.
-  gmshModelGeoAddSurfaceLoop(128, {127, 119, 121, 123, 125, 11}, o);
-  gmshModelGeoAddVolume(129, {128}, o);
+  gmshModelGeoAddSurfaceLoop(128, {127, 119, 121, 123, 125, 11});
+  gmshModelGeoAddVolume(129, {128});
 
   // Extrusion works as expected, by providing a vector of (dim, tag) pairs as
   // input, the translation vector, and a vector of (dim, tag) pairs as output.
diff --git a/demos/api/t3.cpp b/demos/api/t3.cpp
index cb3d8024c5485946ce47fe47d4b1b3e96c65e01b..0c6518fb60c830e48fccfdf216ce0003554d202d 100644
--- a/demos/api/t3.cpp
+++ b/demos/api/t3.cpp
@@ -12,19 +12,18 @@ int main(int argc, char **argv)
 
   // Copied from t1.cpp...
   double lc = 1e-2;
-  int o;
-  gmshModelGeoAddPoint(1, 0, 0, 0, o, lc);
-  gmshModelGeoAddPoint(2, .1, 0,  0, o, lc);
-  gmshModelGeoAddPoint(3, .1, .3, 0, o, lc);
-  gmshModelGeoAddPoint(4, 0,  .3, 0, o, lc);
-
-  gmshModelGeoAddLine(1, 1, 2, o);
-  gmshModelGeoAddLine(2, 3, 2, o);
-  gmshModelGeoAddLine(3, 3, 4, o);
-  gmshModelGeoAddLine(4, 4, 1, o);
-
-  gmshModelGeoAddLineLoop(1, {4, 1, -2, 3}, o);
-  gmshModelGeoAddPlaneSurface(1, {1}, o);
+  gmshModelGeoAddPoint(1, 0, 0, 0, lc);
+  gmshModelGeoAddPoint(2, .1, 0,  0, lc);
+  gmshModelGeoAddPoint(3, .1, .3, 0, lc);
+  gmshModelGeoAddPoint(4, 0,  .3, 0, lc);
+
+  gmshModelGeoAddLine(1, 1, 2);
+  gmshModelGeoAddLine(2, 3, 2);
+  gmshModelGeoAddLine(3, 3, 4);
+  gmshModelGeoAddLine(4, 4, 1);
+
+  gmshModelGeoAddLineLoop(1, {4, 1, -2, 3});
+  gmshModelGeoAddPlaneSurface(1, {1});
   gmshModelAddPhysicalGroup(0, 1, {1, 2});
   gmshModelAddPhysicalGroup(1, 2, {1, 2});
   gmshModelAddPhysicalGroup(2, 6, {1});
diff --git a/demos/api/t4.cpp b/demos/api/t4.cpp
index fd0955e3a21d8e5903fdb6bcb771edb652ae50d1..a8e985a53da03f494e6cc72e73245e6ddf989902 100644
--- a/demos/api/t4.cpp
+++ b/demos/api/t4.cpp
@@ -23,63 +23,63 @@ int main(int argc, char **argv)
   double ssin = sqrt(1 - ccos*ccos);
 
   int o;
-  gmshModelGeoAddPoint(1, -e1-e2, 0    , 0, o, Lc1);
-  gmshModelGeoAddPoint(2, -e1-e2, h1   , 0, o, Lc1);
-  gmshModelGeoAddPoint(3, -e3-r , h1   , 0, o, Lc2);
-  gmshModelGeoAddPoint(4, -e3-r , h1+r , 0, o, Lc2);
-  gmshModelGeoAddPoint(5, -e3   , h1+r , 0, o, Lc2);
-  gmshModelGeoAddPoint(6, -e3   , h1+h2, 0, o, Lc1);
-  gmshModelGeoAddPoint(7,  e3   , h1+h2, 0, o, Lc1);
-  gmshModelGeoAddPoint(8,  e3   , h1+r , 0, o, Lc2);
-  gmshModelGeoAddPoint(9,  e3+r , h1+r , 0, o, Lc2);
-  gmshModelGeoAddPoint(10, e3+r , h1   , 0, o, Lc2);
-  gmshModelGeoAddPoint(11, e1+e2, h1   , 0, o, Lc1);
-  gmshModelGeoAddPoint(12, e1+e2, 0    , 0, o, Lc1);
-  gmshModelGeoAddPoint(13, e2   , 0    , 0, o, Lc1);
-
-  gmshModelGeoAddPoint(14,  R1 / ssin, h5+R1*ccos, 0, o, Lc2);
-  gmshModelGeoAddPoint(15,  0        , h5        , 0, o, Lc2);
-  gmshModelGeoAddPoint(16, -R1 / ssin, h5+R1*ccos, 0, o, Lc2);
-  gmshModelGeoAddPoint(17, -e2       , 0.0       , 0, o, Lc1);
-
-  gmshModelGeoAddPoint(18, -R2 , h1+h3   , 0, o, Lc2);
-  gmshModelGeoAddPoint(19, -R2 , h1+h3+h4, 0, o, Lc2);
-  gmshModelGeoAddPoint(20,  0  , h1+h3+h4, 0, o, Lc2);
-  gmshModelGeoAddPoint(21,  R2 , h1+h3+h4, 0, o, Lc2);
-  gmshModelGeoAddPoint(22,  R2 , h1+h3   , 0, o, Lc2);
-  gmshModelGeoAddPoint(23,  0  , h1+h3   , 0, o, Lc2);
-
-  gmshModelGeoAddPoint(24,  0, h1+h3+h4+R2, 0, o, Lc2);
-  gmshModelGeoAddPoint(25,  0, h1+h3-R2,    0, o, Lc2);
-
-  gmshModelGeoAddLine(1, 1 , 17, o);
-  gmshModelGeoAddLine(2, 17, 16, o);
-
-  gmshModelGeoAddCircleArc(3, 14,15,16, o);
-  gmshModelGeoAddLine(4, 14,13, o);
-  gmshModelGeoAddLine(5, 13,12, o);
-  gmshModelGeoAddLine(6, 12,11, o);
-  gmshModelGeoAddLine(7, 11,10, o);
-  gmshModelGeoAddCircleArc(8, 8,9,10, o);
-  gmshModelGeoAddLine(9, 8,7, o);
-  gmshModelGeoAddLine(10, 7,6, o);
-  gmshModelGeoAddLine(11, 6,5, o);
-  gmshModelGeoAddCircleArc(12, 3,4,5, o);
-  gmshModelGeoAddLine(13, 3,2, o);
-  gmshModelGeoAddLine(14, 2,1, o);
-  gmshModelGeoAddLine(15, 18,19, o);
-  gmshModelGeoAddCircleArc(16, 21,20,24, o);
-  gmshModelGeoAddCircleArc(17, 24,20,19, o);
-  gmshModelGeoAddCircleArc(18, 18,23,25, o);
-  gmshModelGeoAddCircleArc(19, 25,23,22, o);
-  gmshModelGeoAddLine(20, 21,22, o);
-
-  gmshModelGeoAddLineLoop(21, {17,-15,18,19,-20,16}, o);
-  gmshModelGeoAddPlaneSurface(22, {21}, o);
-  gmshModelGeoAddLineLoop(23, {11,-12,13,14,1,2,-3,4,5,6,7,-8,9,10}, o);
+  gmshModelGeoAddPoint(1, -e1-e2, 0    , 0, Lc1);
+  gmshModelGeoAddPoint(2, -e1-e2, h1   , 0, Lc1);
+  gmshModelGeoAddPoint(3, -e3-r , h1   , 0, Lc2);
+  gmshModelGeoAddPoint(4, -e3-r , h1+r , 0, Lc2);
+  gmshModelGeoAddPoint(5, -e3   , h1+r , 0, Lc2);
+  gmshModelGeoAddPoint(6, -e3   , h1+h2, 0, Lc1);
+  gmshModelGeoAddPoint(7,  e3   , h1+h2, 0, Lc1);
+  gmshModelGeoAddPoint(8,  e3   , h1+r , 0, Lc2);
+  gmshModelGeoAddPoint(9,  e3+r , h1+r , 0, Lc2);
+  gmshModelGeoAddPoint(10, e3+r , h1   , 0, Lc2);
+  gmshModelGeoAddPoint(11, e1+e2, h1   , 0, Lc1);
+  gmshModelGeoAddPoint(12, e1+e2, 0    , 0, Lc1);
+  gmshModelGeoAddPoint(13, e2   , 0    , 0, Lc1);
+
+  gmshModelGeoAddPoint(14,  R1 / ssin, h5+R1*ccos, 0, Lc2);
+  gmshModelGeoAddPoint(15,  0        , h5        , 0, Lc2);
+  gmshModelGeoAddPoint(16, -R1 / ssin, h5+R1*ccos, 0, Lc2);
+  gmshModelGeoAddPoint(17, -e2       , 0.0       , 0, Lc1);
+
+  gmshModelGeoAddPoint(18, -R2 , h1+h3   , 0, Lc2);
+  gmshModelGeoAddPoint(19, -R2 , h1+h3+h4, 0, Lc2);
+  gmshModelGeoAddPoint(20,  0  , h1+h3+h4, 0, Lc2);
+  gmshModelGeoAddPoint(21,  R2 , h1+h3+h4, 0, Lc2);
+  gmshModelGeoAddPoint(22,  R2 , h1+h3   , 0, Lc2);
+  gmshModelGeoAddPoint(23,  0  , h1+h3   , 0, Lc2);
+
+  gmshModelGeoAddPoint(24,  0, h1+h3+h4+R2, 0, Lc2);
+  gmshModelGeoAddPoint(25,  0, h1+h3-R2,    0, Lc2);
+
+  gmshModelGeoAddLine(1, 1 , 17);
+  gmshModelGeoAddLine(2, 17, 16);
+
+  gmshModelGeoAddCircleArc(3, 14,15,16);
+  gmshModelGeoAddLine(4, 14,13);
+  gmshModelGeoAddLine(5, 13,12);
+  gmshModelGeoAddLine(6, 12,11);
+  gmshModelGeoAddLine(7, 11,10);
+  gmshModelGeoAddCircleArc(8, 8,9,10);
+  gmshModelGeoAddLine(9, 8,7);
+  gmshModelGeoAddLine(10, 7,6);
+  gmshModelGeoAddLine(11, 6,5);
+  gmshModelGeoAddCircleArc(12, 3,4,5);
+  gmshModelGeoAddLine(13, 3,2);
+  gmshModelGeoAddLine(14, 2,1);
+  gmshModelGeoAddLine(15, 18,19);
+  gmshModelGeoAddCircleArc(16, 21,20,24);
+  gmshModelGeoAddCircleArc(17, 24,20,19);
+  gmshModelGeoAddCircleArc(18, 18,23,25);
+  gmshModelGeoAddCircleArc(19, 25,23,22);
+  gmshModelGeoAddLine(20, 21,22);
+
+  gmshModelGeoAddLineLoop(21, {17,-15,18,19,-20,16});
+  gmshModelGeoAddPlaneSurface(22, {21});
+  gmshModelGeoAddLineLoop(23, {11,-12,13,14,1,2,-3,4,5,6,7,-8,9,10});
 
   // A surface with one hole is specified using 2 line loops:
-  gmshModelGeoAddPlaneSurface(24, {23,21}, o);
+  gmshModelGeoAddPlaneSurface(24, {23,21});
 
   // FIXME: this will be implemented through the gmshView API
   /*
diff --git a/demos/api/t5.cpp b/demos/api/t5.cpp
index f0c57325b4a5d62e2db5ea596dabeabbeef71dfe..8ce20129a0bab54b0ac5198def54fa8f6784764c 100644
--- a/demos/api/t5.cpp
+++ b/demos/api/t5.cpp
@@ -7,48 +7,48 @@ void cheeseHole(double x, double y, double z, double r, double lc,
                 std::vector<int> &shells, std::vector<int> &volumes)
 {
   // When the tag (first argument) is negative, the next available tag for the
-  // corresponding entity is returned as the 5th argument (e.g. p1)
-  int p1; gmshModelGeoAddPoint(-1, x,  y,  z,  p1, lc);
-  int p2; gmshModelGeoAddPoint(-1, x+r,y,  z,  p2, lc);
-  int p3; gmshModelGeoAddPoint(-1, x,  y+r,z,  p3, lc);
-  int p4; gmshModelGeoAddPoint(-1, x,  y,  z+r,p4, lc);
-  int p5; gmshModelGeoAddPoint(-1, x-r,y,  z,  p5, lc);
-  int p6; gmshModelGeoAddPoint(-1, x,  y-r,z,  p6, lc);
-  int p7; gmshModelGeoAddPoint(-1, x,  y,  z-r,p7, lc);
-
-  int c1; gmshModelGeoAddCircleArc(-1, p2,p1,p7, c1);
-  int c2; gmshModelGeoAddCircleArc(-1, p7,p1,p5, c2);
-  int c3; gmshModelGeoAddCircleArc(-1, p5,p1,p4, c3);
-  int c4; gmshModelGeoAddCircleArc(-1, p4,p1,p2, c4);
-  int c5; gmshModelGeoAddCircleArc(-1, p2,p1,p3, c5);
-  int c6; gmshModelGeoAddCircleArc(-1, p3,p1,p5, c6);
-  int c7; gmshModelGeoAddCircleArc(-1, p5,p1,p6, c7);
-  int c8; gmshModelGeoAddCircleArc(-1, p6,p1,p2, c8);
-  int c9; gmshModelGeoAddCircleArc(-1, p7,p1,p3, c9);
-  int c10; gmshModelGeoAddCircleArc(-1, p3,p1,p4, c10);
-  int c11; gmshModelGeoAddCircleArc(-1, p4,p1,p6, c11);
-  int c12; gmshModelGeoAddCircleArc(-1, p6,p1,p7, c12);
-
-  int l1; gmshModelGeoAddLineLoop(-1, {c5,c10,c4}, l1);
-  int l2; gmshModelGeoAddLineLoop(-1, {c9,-c5,c1}, l2);
-  int l3; gmshModelGeoAddLineLoop(-1, {c12,-c8,-c1}, l3);
-  int l4; gmshModelGeoAddLineLoop(-1, {c8,-c4,c11}, l4);
-  int l5; gmshModelGeoAddLineLoop(-1, {-c10,c6,c3}, l5);
-  int l6; gmshModelGeoAddLineLoop(-1, {-c11,-c3,c7}, l6);
-  int l7; gmshModelGeoAddLineLoop(-1, {-c2,-c7,-c12}, l7);
-  int l8; gmshModelGeoAddLineLoop(-1, {-c6,-c9,c2}, l8);
-
-  int s1; gmshModelGeoAddSurfaceFilling(-1, {l1}, s1);
-  int s2; gmshModelGeoAddSurfaceFilling(-1, {l2}, s2);
-  int s3; gmshModelGeoAddSurfaceFilling(-1, {l3}, s3);
-  int s4; gmshModelGeoAddSurfaceFilling(-1, {l4}, s4);
-  int s5; gmshModelGeoAddSurfaceFilling(-1, {l5}, s5);
-  int s6; gmshModelGeoAddSurfaceFilling(-1, {l6}, s6);
-  int s7; gmshModelGeoAddSurfaceFilling(-1, {l7}, s7);
-  int s8; gmshModelGeoAddSurfaceFilling(-1, {l8}, s8);
-
-  int sl; gmshModelGeoAddSurfaceLoop(-1, {s1, s2, s3, s4, s5, s6, s7, s8}, sl);
-  int v; gmshModelGeoAddVolume(-1, {sl}, v);
+  // corresponding entity is appended to the returned value
+  int p1 = gmshModelGeoAddPoint(-1, x,  y,  z,  lc)[1];
+  int p2 = gmshModelGeoAddPoint(-1, x+r,y,  z,   lc)[1];
+  int p3 = gmshModelGeoAddPoint(-1, x,  y+r,z,   lc)[1];
+  int p4 = gmshModelGeoAddPoint(-1, x,  y,  z+r, lc)[1];
+  int p5 = gmshModelGeoAddPoint(-1, x-r,y,  z,   lc)[1];
+  int p6 = gmshModelGeoAddPoint(-1, x,  y-r,z,   lc)[1];
+  int p7 = gmshModelGeoAddPoint(-1, x,  y,  z-r, lc)[1];
+
+  int c1 = gmshModelGeoAddCircleArc(-1, p2,p1,p7)[1];
+  int c2 = gmshModelGeoAddCircleArc(-1, p7,p1,p5)[1];
+  int c3 = gmshModelGeoAddCircleArc(-1, p5,p1,p4)[1];
+  int c4 = gmshModelGeoAddCircleArc(-1, p4,p1,p2)[1];
+  int c5 = gmshModelGeoAddCircleArc(-1, p2,p1,p3)[1];
+  int c6 = gmshModelGeoAddCircleArc(-1, p3,p1,p5)[1];
+  int c7 = gmshModelGeoAddCircleArc(-1, p5,p1,p6)[1];
+  int c8 = gmshModelGeoAddCircleArc(-1, p6,p1,p2)[1];
+  int c9 = gmshModelGeoAddCircleArc(-1, p7,p1,p3)[1];
+  int c10 = gmshModelGeoAddCircleArc(-1, p3,p1,p4)[1];
+  int c11 = gmshModelGeoAddCircleArc(-1, p4,p1,p6)[1];
+  int c12 = gmshModelGeoAddCircleArc(-1, p6,p1,p7)[1];
+
+  int l1 = gmshModelGeoAddLineLoop(-1, {c5,c10,c4})[1];
+  int l2 = gmshModelGeoAddLineLoop(-1, {c9,-c5,c1})[1];
+  int l3 = gmshModelGeoAddLineLoop(-1, {c12,-c8,-c1})[1];
+  int l4 = gmshModelGeoAddLineLoop(-1, {c8,-c4,c11})[1];
+  int l5 = gmshModelGeoAddLineLoop(-1, {-c10,c6,c3})[1];
+  int l6 = gmshModelGeoAddLineLoop(-1, {-c11,-c3,c7})[1];
+  int l7 = gmshModelGeoAddLineLoop(-1, {-c2,-c7,-c12})[1];
+  int l8 = gmshModelGeoAddLineLoop(-1, {-c6,-c9,c2})[1];
+
+  int s1 = gmshModelGeoAddSurfaceFilling(-1, {l1})[1];
+  int s2 = gmshModelGeoAddSurfaceFilling(-1, {l2})[1];
+  int s3 = gmshModelGeoAddSurfaceFilling(-1, {l3})[1];
+  int s4 = gmshModelGeoAddSurfaceFilling(-1, {l4})[1];
+  int s5 = gmshModelGeoAddSurfaceFilling(-1, {l5})[1];
+  int s6 = gmshModelGeoAddSurfaceFilling(-1, {l6})[1];
+  int s7 = gmshModelGeoAddSurfaceFilling(-1, {l7})[1];
+  int s8 = gmshModelGeoAddSurfaceFilling(-1, {l8})[1];
+
+  int sl = gmshModelGeoAddSurfaceLoop(-1, {s1, s2, s3, s4, s5, s6, s7, s8})[1];
+  int v = gmshModelGeoAddVolume(-1, {sl})[1];
   shells.push_back(sl);
   volumes.push_back(v);
 }
@@ -63,65 +63,65 @@ int main(int argc, char **argv)
   double lcar3 = .055;
 
   int o;
-  gmshModelGeoAddPoint(1, 0.5,0.5,0.5, o, lcar2);
-  gmshModelGeoAddPoint(2, 0.5,0.5,0, o, lcar1);
-  gmshModelGeoAddPoint(3, 0,0.5,0.5, o, lcar1);
-  gmshModelGeoAddPoint(4, 0,0,0.5, o, lcar1);
-  gmshModelGeoAddPoint(5, 0.5,0,0.5, o, lcar1);
-  gmshModelGeoAddPoint(6, 0.5,0,0, o, lcar1);
-  gmshModelGeoAddPoint(7, 0,0.5,0, o, lcar1);
-  gmshModelGeoAddPoint(8, 0,1,0, o, lcar1);
-  gmshModelGeoAddPoint(9, 1,1,0, o, lcar1);
-  gmshModelGeoAddPoint(10, 0,0,1, o, lcar1);
-  gmshModelGeoAddPoint(11, 0,1,1, o, lcar1);
-  gmshModelGeoAddPoint(12, 1,1,1, o, lcar1);
-  gmshModelGeoAddPoint(13, 1,0,1, o, lcar1);
-  gmshModelGeoAddPoint(14, 1,0,0, o, lcar1);
-
-  gmshModelGeoAddLine(1, 8,9, o);
-  gmshModelGeoAddLine(2, 9,12, o);
-  gmshModelGeoAddLine(3, 12,11, o);
-  gmshModelGeoAddLine(4, 11,8, o);
-  gmshModelGeoAddLine(5, 9,14, o);
-  gmshModelGeoAddLine(6, 14,13, o);
-  gmshModelGeoAddLine(7, 13,12, o);
-  gmshModelGeoAddLine(8, 11,10, o);
-  gmshModelGeoAddLine(9, 10,13, o);
-  gmshModelGeoAddLine(10, 10,4, o);
-  gmshModelGeoAddLine(11, 4,5, o);
-  gmshModelGeoAddLine(12, 5,6, o);
-  gmshModelGeoAddLine(13, 6,2, o);
-  gmshModelGeoAddLine(14, 2,1, o);
-  gmshModelGeoAddLine(15, 1,3, o);
-  gmshModelGeoAddLine(16, 3,7, o);
-  gmshModelGeoAddLine(17, 7,2, o);
-  gmshModelGeoAddLine(18, 3,4, o);
-  gmshModelGeoAddLine(19, 5,1, o);
-  gmshModelGeoAddLine(20, 7,8, o);
-  gmshModelGeoAddLine(21, 6,14, o);
-
-  gmshModelGeoAddLineLoop(22, {-11,-19,-15,-18}, o);
-  gmshModelGeoAddPlaneSurface(23, {22}, o);
-  gmshModelGeoAddLineLoop(24, {16,17,14,15}, o);
-  gmshModelGeoAddPlaneSurface(25, {24}, o);
-  gmshModelGeoAddLineLoop(26, {-17,20,1,5,-21,13}, o);
-  gmshModelGeoAddPlaneSurface(27, {26}, o);
-  gmshModelGeoAddLineLoop(28, {-4,-1,-2,-3}, o);
-  gmshModelGeoAddPlaneSurface(29, {28}, o);
-  gmshModelGeoAddLineLoop(30, {-7,2,-5,-6}, o);
-  gmshModelGeoAddPlaneSurface(31, {30}, o);
-  gmshModelGeoAddLineLoop(32, {6,-9,10,11,12,21}, o);
-  gmshModelGeoAddPlaneSurface(33, {32}, o);
-  gmshModelGeoAddLineLoop(34, {7,3,8,9}, o);
-  gmshModelGeoAddPlaneSurface(35, {34}, o);
-  gmshModelGeoAddLineLoop(36, {-10,18,-16,-20,4,-8}, o);
-  gmshModelGeoAddPlaneSurface(37, {36}, o);
-  gmshModelGeoAddLineLoop(38, {-14,-13,-12,19}, o);
-  gmshModelGeoAddPlaneSurface(39, {38}, o);
+  gmshModelGeoAddPoint(1, 0.5,0.5,0.5, lcar2);
+  gmshModelGeoAddPoint(2, 0.5,0.5,0, lcar1);
+  gmshModelGeoAddPoint(3, 0,0.5,0.5, lcar1);
+  gmshModelGeoAddPoint(4, 0,0,0.5, lcar1);
+  gmshModelGeoAddPoint(5, 0.5,0,0.5, lcar1);
+  gmshModelGeoAddPoint(6, 0.5,0,0, lcar1);
+  gmshModelGeoAddPoint(7, 0,0.5,0, lcar1);
+  gmshModelGeoAddPoint(8, 0,1,0, lcar1);
+  gmshModelGeoAddPoint(9, 1,1,0, lcar1);
+  gmshModelGeoAddPoint(10, 0,0,1, lcar1);
+  gmshModelGeoAddPoint(11, 0,1,1, lcar1);
+  gmshModelGeoAddPoint(12, 1,1,1, lcar1);
+  gmshModelGeoAddPoint(13, 1,0,1, lcar1);
+  gmshModelGeoAddPoint(14, 1,0,0, lcar1);
+
+  gmshModelGeoAddLine(1, 8,9);
+  gmshModelGeoAddLine(2, 9,12);
+  gmshModelGeoAddLine(3, 12,11);
+  gmshModelGeoAddLine(4, 11,8);
+  gmshModelGeoAddLine(5, 9,14);
+  gmshModelGeoAddLine(6, 14,13);
+  gmshModelGeoAddLine(7, 13,12);
+  gmshModelGeoAddLine(8, 11,10);
+  gmshModelGeoAddLine(9, 10,13);
+  gmshModelGeoAddLine(10, 10,4);
+  gmshModelGeoAddLine(11, 4,5);
+  gmshModelGeoAddLine(12, 5,6);
+  gmshModelGeoAddLine(13, 6,2);
+  gmshModelGeoAddLine(14, 2,1);
+  gmshModelGeoAddLine(15, 1,3);
+  gmshModelGeoAddLine(16, 3,7);
+  gmshModelGeoAddLine(17, 7,2);
+  gmshModelGeoAddLine(18, 3,4);
+  gmshModelGeoAddLine(19, 5,1);
+  gmshModelGeoAddLine(20, 7,8);
+  gmshModelGeoAddLine(21, 6,14);
+
+  gmshModelGeoAddLineLoop(22, {-11,-19,-15,-18});
+  gmshModelGeoAddPlaneSurface(23, {22});
+  gmshModelGeoAddLineLoop(24, {16,17,14,15});
+  gmshModelGeoAddPlaneSurface(25, {24});
+  gmshModelGeoAddLineLoop(26, {-17,20,1,5,-21,13});
+  gmshModelGeoAddPlaneSurface(27, {26});
+  gmshModelGeoAddLineLoop(28, {-4,-1,-2,-3});
+  gmshModelGeoAddPlaneSurface(29, {28});
+  gmshModelGeoAddLineLoop(30, {-7,2,-5,-6});
+  gmshModelGeoAddPlaneSurface(31, {30});
+  gmshModelGeoAddLineLoop(32, {6,-9,10,11,12,21});
+  gmshModelGeoAddPlaneSurface(33, {32});
+  gmshModelGeoAddLineLoop(34, {7,3,8,9});
+  gmshModelGeoAddPlaneSurface(35, {34});
+  gmshModelGeoAddLineLoop(36, {-10,18,-16,-20,4,-8});
+  gmshModelGeoAddPlaneSurface(37, {36});
+  gmshModelGeoAddLineLoop(38, {-14,-13,-12,19});
+  gmshModelGeoAddPlaneSurface(39, {38});
 
   std::vector<int> shells, volumes;
 
-  int sl; gmshModelGeoAddSurfaceLoop(-1, {35,31,29,37,33,23,39,25,27}, sl);
+  int sl = gmshModelGeoAddSurfaceLoop(-1, {35,31,29,37,33,23,39,25,27})[1];
   shells.push_back(sl);
 
   double x = 0, y = 0.75, z = 0, r = 0.09 ;
@@ -134,7 +134,7 @@ int main(int argc, char **argv)
                 t, x, y, z, r, volumes.back());
   }
 
-  int v; gmshModelGeoAddVolume(186, shells, v);
+  int v = gmshModelGeoAddVolume(186, shells)[1];
 
   gmshModelAddPhysicalGroup(3, 10, {186});
   gmshModelGeoSynchronize();
diff --git a/demos/api/t6.cpp b/demos/api/t6.cpp
index 528b02adf87d0b974422eb6336a16986a54a9287..da2a203436bb77dfbc9b252564c1c25b95abfdc2 100644
--- a/demos/api/t6.cpp
+++ b/demos/api/t6.cpp
@@ -11,19 +11,18 @@ int main(int argc, char **argv)
 
   // Copied from t1.cpp...
   double lc = 1e-2;
-  int o;
-  gmshModelGeoAddPoint(1, 0, 0, 0, o, lc);
-  gmshModelGeoAddPoint(2, .1, 0,  0, o, lc);
-  gmshModelGeoAddPoint(3, .1, .3, 0, o, lc);
-  gmshModelGeoAddPoint(4, 0,  .3, 0, o, lc);
-
-  gmshModelGeoAddLine(1, 1, 2, o);
-  gmshModelGeoAddLine(2, 3, 2, o);
-  gmshModelGeoAddLine(3, 3, 4, o);
-  gmshModelGeoAddLine(4, 4, 1, o);
-
-  gmshModelGeoAddLineLoop(1, {4, 1, -2, 3}, o);
-  gmshModelGeoAddPlaneSurface(1, {1}, o);
+  gmshModelGeoAddPoint(1, 0, 0, 0, lc);
+  gmshModelGeoAddPoint(2, .1, 0,  0, lc);
+  gmshModelGeoAddPoint(3, .1, .3, 0, lc);
+  gmshModelGeoAddPoint(4, 0,  .3, 0, lc);
+
+  gmshModelGeoAddLine(1, 1, 2);
+  gmshModelGeoAddLine(2, 3, 2);
+  gmshModelGeoAddLine(3, 3, 4);
+  gmshModelGeoAddLine(4, 4, 1);
+
+  gmshModelGeoAddLineLoop(1, {4, 1, -2, 3});
+  gmshModelGeoAddPlaneSurface(1, {1});
   gmshModelAddPhysicalGroup(0, 1, {1, 2});
   gmshModelAddPhysicalGroup(1, 2, {1, 2});
   gmshModelAddPhysicalGroup(2, 6, {1});
@@ -34,15 +33,15 @@ int main(int argc, char **argv)
   gmshModelGeoRemove({{2,1}, {1,4}});
 
   // Replace left boundary with 3 new lines
-  int p1; gmshModelGeoAddPoint(-1, -0.05, 0.05, 0, p1, lc);
-  int p2; gmshModelGeoAddPoint(-1, -0.05, 0.1, 0, p2, lc);
-  int l1; gmshModelGeoAddLine(-1, 1, p1, l1);
-  int l2; gmshModelGeoAddLine(-1, p1, p2, l2);
-  int l3; gmshModelGeoAddLine(-1, p2, 4, l3);
+  int p1 = gmshModelGeoAddPoint(-1, -0.05, 0.05, 0, lc)[1];
+  int p2 = gmshModelGeoAddPoint(-1, -0.05, 0.1, 0, lc)[1];
+  int l1 = gmshModelGeoAddLine(-1, 1, p1)[1];
+  int l2 = gmshModelGeoAddLine(-1, p1, p2)[1];
+  int l3 = gmshModelGeoAddLine(-1, p2, 4)[1];
 
   // Recreate surface
-  gmshModelGeoAddLineLoop(2, {2, -1, l1, l2, l3, -3}, o);
-  gmshModelGeoAddPlaneSurface(1, {-2}, o);
+  gmshModelGeoAddLineLoop(2, {2, -1, l1, l2, l3, -3});
+  gmshModelGeoAddPlaneSurface(1, {-2});
 
   // Put 20 points with a refinement toward the extremities on curve 2
   gmshModelGeoSetTransfiniteLine(2, 20, "Bump", 0.05);
@@ -72,17 +71,17 @@ int main(int argc, char **argv)
 
   // When the surface has only 3 or 4 control points, the transfinite constraint
   // can be applied automatically (without specifying the corners explictly).
-  gmshModelGeoAddPoint(7, 0.2, 0.2, 0, o, 1.0);
-  gmshModelGeoAddPoint(8, 0.2, 0.1, 0, o, 1.0);
-  gmshModelGeoAddPoint(9, 0, 0.3, 0, o, 1.0);
-  gmshModelGeoAddPoint(10, 0.25, 0.2, 0, o, 1.0);
-  gmshModelGeoAddPoint(11, 0.3, 0.1, 0, o, 1.0);
-  gmshModelGeoAddLine(10, 8, 11, o);
-  gmshModelGeoAddLine(11, 11, 10, o);
-  gmshModelGeoAddLine(12, 10, 7, o);
-  gmshModelGeoAddLine(13, 7, 8, o);
-  gmshModelGeoAddLineLoop(14, {13, 10, 11, 12}, o);
-  gmshModelGeoAddPlaneSurface(15, {14}, o);
+  gmshModelGeoAddPoint(7, 0.2, 0.2, 0, 1.0);
+  gmshModelGeoAddPoint(8, 0.2, 0.1, 0, 1.0);
+  gmshModelGeoAddPoint(9, 0, 0.3, 0, 1.0);
+  gmshModelGeoAddPoint(10, 0.25, 0.2, 0, 1.0);
+  gmshModelGeoAddPoint(11, 0.3, 0.1, 0, 1.0);
+  gmshModelGeoAddLine(10, 8, 11);
+  gmshModelGeoAddLine(11, 11, 10);
+  gmshModelGeoAddLine(12, 10, 7);
+  gmshModelGeoAddLine(13, 7, 8);
+  gmshModelGeoAddLineLoop(14, {13, 10, 11, 12});
+  gmshModelGeoAddPlaneSurface(15, {14});
   for(int i = 10; i <= 13; i++)
     gmshModelGeoSetTransfiniteLine(i, 10);
   gmshModelGeoSetTransfiniteSurface(15);