[Therion] Weird Error

Olly Betts olly at survex.com
Wed Dec 14 10:08:27 CET 2005


On Wed, Dec 14, 2005 at 07:47:42AM +0100, Stacho Mudrak wrote:
> Quoting Philip Schuchardt <ohc at vt.edu>:
> > Just add -m32 option to the compiler and linker flags.
> 
> Great, thanks a lot. We will add it soon.

This is really a workaround rather than a fix - it assumes you've got a
multilibbed compiler and all the required libraries compiled as 32 bit.
So it won't even work for all x86_64 Linux users, let alone other 64
bit platforms which don't have a 32 bit mode.

Really, the underlying bug (presumably an assumption that sizeof(long)
== 4 or sizeof(void*) == sizeof(int) or similar) needs fixing.

Here's a patch which at least gets us some way along that road.  It may
even be a complete fix - the therion project I had to hand goes from
dying with the error Philip reported to complaining that it doesn't know
about "left" which could just be because it's too old.  I don't really
have time to dig deeper right now.

Cheers,
    Olly
-------------- next part --------------
diff -ru therion-0.3.9-orig/thexpmodel.cxx therion-0.3.9/thexpmodel.cxx
--- therion-0.3.9-orig/thexpmodel.cxx	2005-05-12 21:03:46.000000000 +0100
+++ therion-0.3.9/thexpmodel.cxx	2005-12-14 08:48:58.800754176 +0000
@@ -1362,7 +1362,7 @@
       sptr = (thsurvey*)(*obi);
       if (sptr->num1 > 0) {
         sptr->num1 = survnum++;
-        fprintf(pltf,"S %d %d %s\n", sptr->num1, (sptr->fsptr != NULL) ? sptr->fsptr->num1 : -1, sptr->name);
+        fprintf(pltf,"S %ld %ld %s\n", sptr->num1, (sptr->fsptr != NULL) ? sptr->fsptr->num1 : -1, sptr->name);
         if (strlen(sptr->title)) {
           fprintf(pltf,"C %s\n", sptr->title);
         }
@@ -1379,7 +1379,7 @@
     if (stnum[i] > 0) {
       stnum[i] = survnum;
       pst = &(dbp->db1d.station_vec[i]);
-      fprintf(pltf,"T %d %d %s %.3f %.3f %.3f G%s%s%s\n", survnum, pst->survey->num1, pst->name, pst->x, pst->y, pst->z, (pst->flags & TT_STATIONFLAG_ENTRANCE) != 0 ? "E" : "", (pst->flags & TT_STATIONFLAG_FIXED) != 0 ? "F" : "", (pst->flags & TT_STATIONFLAG_CONT) != 0 ? "C" : "");
+      fprintf(pltf,"T %ld %ld %s %.3f %.3f %.3f G%s%s%s\n", survnum, pst->survey->num1, pst->name, pst->x, pst->y, pst->z, (pst->flags & TT_STATIONFLAG_ENTRANCE) != 0 ? "E" : "", (pst->flags & TT_STATIONFLAG_FIXED) != 0 ? "F" : "", (pst->flags & TT_STATIONFLAG_CONT) != 0 ? "C" : "");
       if (pst->comment != NULL) {
         fprintf(pltf,"C %s\n", pst->comment);
       }
@@ -1392,7 +1392,7 @@
   tlegs = dbp->db1d.get_tree_legs();
   for(i = 0; i < nlegs; i++, tlegs++) {
     if ((*tlegs)->survey->is_selected()) {
-      fprintf(pltf,"H %d %d %d G%s%s\n", 
+      fprintf(pltf,"H %ld %ld %ld G%s%s\n", 
           stnum[(*tlegs)->leg->from.id - 1],
           stnum[(*tlegs)->leg->to.id - 1],
           (*tlegs)->survey->num1,
@@ -1416,7 +1416,7 @@
         case TT_SURFACE_CMD:
           tmp3d = ((thsurface*)(*obi))->get_3d();
           if ((tmp3d != NULL) && (tmp3d->nfaces > 0)) {
-            fprintf(pltf,"X 1 %d\n", ((thsurface*)(*obi))->fsptr->num1);
+            fprintf(pltf,"X 1 %ld\n", ((thsurface*)(*obi))->fsptr->num1);
             tmp3d->exp_shift_x = 0.0;
             tmp3d->exp_shift_y = 0.0;
             tmp3d->exp_shift_z = 0.0;
@@ -1447,7 +1447,7 @@
             d3d->exp_shift_x = 0.0;
             d3d->exp_shift_y = 0.0;
             d3d->exp_shift_z = 0.0;
-            fprintf(pltf,"X 0 %d\n", cs->fsptr->num1);
+            fprintf(pltf,"X 0 %ld\n", cs->fsptr->num1);
             d3d->export_tlx(pltf);
           }
         }
diff -ru therion-0.3.9-orig/thtexfonts.cxx therion-0.3.9/thtexfonts.cxx
--- therion-0.3.9-orig/thtexfonts.cxx	2005-05-05 12:20:53.000000000 +0100
+++ therion-0.3.9/thtexfonts.cxx	2005-12-14 08:49:29.025159368 +0000
@@ -147,7 +147,7 @@
 }
 
 string replace_all(string s, string f, string r) {
-  unsigned int found = s.find(f);
+  size_t found = s.find(f);
   while(found != string::npos) {
     s.replace(found, f.length(), r);
     found = s.find(f);


More information about the Therion mailing list