Selon Andy Ross:
> Please try again, this time in C, and let me know the error you are
> seeing.  I strongly suspect you've been fooled by a much simpler
> issue.

OK, I backed out all my changes and restart the compilation. I found where it is
not C : you don't always declare local variables at the beginning of functions
but you have the C++ habit to declare them as you need them. So the change
below are needed and they are much simpler than yesterday evening ;-) With them
the compilation is seamless and the warning on empty arrays disappeared as other
C++ oddness ;-) Then change in GC_HEADER is required though.

cvs -z4 -q diff -u code.c data.h lib.c misc.c (in directory
I:\FlightGear\cvs\SimGear\simgear\nasal\)
Index: code.c
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/nasal/code.c,v
retrieving revision 1.8
diff -u -r1.8 code.c
--- code.c      18 Apr 2005 19:48:47 -0000      1.8
+++ code.c      19 Apr 2005 06:18:24 -0000
@@ -107,13 +107,14 @@

 static void initGlobals()
 {
+    int i;
+    struct Context* c;
     globals = (struct Globals*)naAlloc(sizeof(struct Globals));
     naBZero(globals, sizeof(struct Globals));

     globals->sem = naNewSem();
     globals->lock = naNewLock();

-    int i;
     globals->allocCount = 256; // reasonable starting value
     for(i=0; i<NUM_NASAL_TYPES; i++)
         naGC_init(&(globals->pools[i]), i);
@@ -124,7 +125,7 @@
     // Initialize a single context
     globals->freeContexts = 0;
     globals->allContexts = 0;
-    struct Context* c = naNewContext();
+    c = naNewContext();

     globals->symbols = naNewHash(c);
     globals->save = naNewVector(c);
@@ -140,11 +141,12 @@
 struct Context* naNewContext()
 {
     int dummy;
+    struct Context* c;
     if(globals == 0)
         initGlobals();

     LOCK();
-    struct Context* c = globals->freeContexts;
+    c = globals->freeContexts;
     if(c) {
         globals->freeContexts = c->nextFree;
         c->nextFree = 0;
Index: data.h
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/nasal/data.h,v
retrieving revision 1.3
diff -u -r1.3 data.h
--- data.h      18 Apr 2005 19:48:47 -0000      1.3
+++ data.h      19 Apr 2005 06:10:30 -0000
@@ -33,7 +33,7 @@
 // implementing objects to pack in 16 bits worth of data "for free".
 #define GC_HEADER \
     unsigned char mark; \
-    unsigned char type; \
+    unsigned char type

 struct naObj {
     GC_HEADER;
Index: lib.c
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/nasal/lib.c,v
retrieving revision 1.6
diff -u -r1.6 lib.c
--- lib.c       18 Apr 2005 19:48:47 -0000      1.6
+++ lib.c       19 Apr 2005 06:17:09 -0000
@@ -49,8 +49,9 @@

 static naRef setsize(naContext c, naRef me, int argc, naRef* args)
 {
+    int sz;
     if(argc < 2) return naNil();
-    int sz = (int)naNumValue(args[1]).num;
+    sz = (int)naNumValue(args[1]).num;
     if(!naIsVector(args[0])) return naNil();
     naVec_setsize(args[0], sz);
     return args[0];
Index: misc.c
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/nasal/misc.c,v
retrieving revision 1.4
diff -u -r1.4 misc.c
--- misc.c      18 Apr 2005 19:48:47 -0000      1.4
+++ misc.c      19 Apr 2005 06:17:09 -0000
@@ -49,10 +49,11 @@

 naRef naNew(struct Context* c, int type)
 {
+    naRef result;
     if(c->nfree[type] == 0)
         c->free[type] = naGC_get(&globals->pools[type],
                                  OBJ_CACHE_SZ, &c->nfree[type]);
-    naRef result = naObj(type, c->free[type][--c->nfree[type]]);
+    result = naObj(type, c->free[type][--c->nfree[type]]);
     naVec_append(c->temps, result);
     return result;
 }

_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to