August 17, 2003
Walter -

You fixed the problem on the minimal sample program, which was a complete program. However, compiling the offending module from the real library gives a syntax error. See the following:

------------------------8< beg >8------------------------
/* t2.c
*     test sqlite style function table
*/
typedef struct B B;
typedef struct flist flist;
typedef struct flist2 flist2;

struct flist   {
   int (*f1)(B*);
   };

struct B   {
   flist*   flp;
   };

static flist funList;

void initB( B* b )
   {
   b->flp = &funList;
   showB(b);
   }

int f1( B* b )
   {
   return 0;
   }

static flist funList = { f1 };
------------------------8< end >8------------------------

E>dmc -c t2.c
t2.c(30) : Error: no definition for static 'funList'
--- errorlevel 1


 ../frank
August 17, 2003
I forgot to mention a simple workaround: The syntax error doesn't occur if there's a valid reference to 'funList' after the redefinition.

Since this code occurs in library module, a neat workaround is to put a function like this one at the end of the source file:

static void f() { flist* f = &funList; }



On Sun, 17 Aug 2003 02:35:40 -0500, Frank Albe <falbe@mindspring.com> wrote:

>Walter -
>
>You fixed the problem on the minimal sample program, which was a complete program. However, compiling the offending module from the real library gives a syntax error. See the following:
>
>------------------------8< beg >8------------------------
>/* t2.c
>*     test sqlite style function table
>*/
>typedef struct B B;
>typedef struct flist flist;
>typedef struct flist2 flist2;
>
>struct flist   {
>   int (*f1)(B*);
>   };
>
>struct B   {
>   flist*   flp;
>   };
>
>static flist funList;
>
>void initB( B* b )
>   {
>   b->flp = &funList;
>   showB(b);
>   }
>
>int f1( B* b )
>   {
>   return 0;
>   }
>
>static flist funList = { f1 };
>------------------------8< end >8------------------------
>
>E>dmc -c t2.c
>t2.c(30) : Error: no definition for static 'funList'
>--- errorlevel 1
>
>
> ../frank

 ../frank