14 Jan, 2009, Jaegar wrote in the 1st comment:
Votes: 0
I have removed another version of a note system and replaced it with a board system. When I compile I am receiving the following errors

gcc -c -Wall -O -ggdb -Dunix -DOLD_RAND -DNOCRYPT act_comm.c
In file included from merc.h:12,
from act_comm.c:40:
board.h:39: error: expected specifier-qualifier-list before âNOTE_DATAâ
board.h:54: error: expected declaration specifiers or â…â before âNOTE_DATAâ
board.h:55: error: expected â)â before â*â token
board.h:58: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âis_note_toâ
board.h:64: error: expected â)â before â*â token
board.h:65: error: expected â)â before â*â token
board.h:66: error: expected â)â before â*â token
board.h:67: error: expected â)â before â*â token
board.h:68: error: expected â)â before â*â token
board.h:73: warning: data definition has no type or storage class
board.h:73: warning: type defaults to âintâ in declaration of âDECLARE_DO_FUNâ
board.h:73: warning: parameter names (without types) in function declaration
board.h:74: warning: data definition has no type or storage class
board.h:74: warning: type defaults to âintâ in declaration of âDECLARE_DO_FUNâ
board.h:74: warning: parameter names (without types) in function declaration
act_comm.c: In function âdo_quitâ:
act_comm.c:1509: warning: implicit declaration of function âfree_noteâ
make: *** [act_comm.o] Error 1


I have added #include board.h to the merc.h file and am unable to determine why I am getting this error.

I am using Rom2.4b6. Any help would be appreciated.

Thanks in advance.
14 Jan, 2009, Sharmair wrote in the 2nd comment:
Votes: 0
It looks like there are some types (or other identifiers) used by board.h that are not
defined at the point in merc.h board.h is included. If you post the code from board.h
from around line 39 at least, we would be better able to determine what the code
needs. If it is an out of place definition, just changing the order of the code (moving
the include of board.h down, or placing the needed definition before the include)
should fix the problem. It is also possible a needed definition is totally missing, or
board.h itself has an error. Showing the code will also help if that is the case. Also
note that in cases like this (when you have a lot of errors like this) it is best to work
on the first one and not worry that much about the later ones, as the first might be
throwing the compile out of sync and will vanish once the original is fixed.
14 Jan, 2009, Jaegar wrote in the 3rd comment:
Votes: 0
Here is the code for the board_data

/* Data about a board */
struct board_data
{
char *short_name; /* Max 8 chars */
char *long_name; /* Explanatory text, should be no more than 40 ? chars */

int read_level; /* minimum level to see board */
int write_level;/* minimum level to post notes */

char *names; /* Default recipient */
int force_type; /* Default action (DEF_XXX) */

int purge_days; /* Default expiration */

/* Non-constant data */

NOTE_DATA *note_first; /* pointer to board's first note */ <– line 39
bool changed; /* currently unused */

};


Thanks for the quick response.
14 Jan, 2009, Davion wrote in the 4th comment:
Votes: 0
The struct definition for NOTE_DATA must be made prior to the use of it. If not, then you can use some form of forward declaration… like a typedef! I'm sure it's in there somewhere. Just look for something like
typedef struct note_data NOTE_DATA;
and move it above the definition for board_data.
14 Jan, 2009, Jaegar wrote in the 5th comment:
Votes: 0
Here are the following declarations from merc.h

typedef struct note_data NOTE_DATA;

then further down in merc.h

/*
* Data structure for notes.
*/
struct note_data
{
NOTE_DATA * next;
bool valid;
sh_int type;
char * sender;
char * date;
char * to_list;
char * subject;
char * text;
time_t date_stamp;
time_t expire;
};
14 Jan, 2009, Davion wrote in the 6th comment:
Votes: 0
Oh, I'm aware of what the look like :P. Here's an example of what your problem is…

struct this_data
{ SOME_DATA * var;
};

struct some_data
{ int other_var;
};


This code will raise the same error you're getting. The reason is, when the compiler (gcc… the thing that's invoked when you type 'make') doesn't know what SOME_DATA is. Compilers are case sensitive, so it has -no- idea what SOME_DATA is. For this, in C, we use something called a type def. Now the same code, with a typedef…

typedef struct some_data SOME_DATA;

struct this_data
{ SOME_DATA * var;
};

struct some_data
{ int other_var;
};


will no longer raise a warning. Because you're telling the compiler that you have a struct named some_data, and we're calling it SOME_DATA. Don't worry Mr. Compiler, once you link you'll see it all, so go along with it for now. I'm guessing that somewhere in your code, the typedef for NOTE_DATA is below the struct board_data definition. What you'd have to do is make sure they're in the right order. You must make sure that the typedef is -before- any usage, so something like

struct this_data
{ SOME_DATA * var;
};
typedef struct some_data SOME_DATA;
struct some_data
{ int other_var;
};


this, is still wrong. Also, when dealing with #include, you just have to realize that it's essentially taking the code from the .h and putting it in there. So lets say this.h is something like this.

struct this_data
{ SOME_DATA *var;
};


Then in main.h we have

#include "this.h"
typedef struct some_data SOME_DATA;
struct some_data
{ int another_var;
};


This is still wrong. For this to be correct, and compile, the typedef would have to be before the #include. Or, it could be before the struct this_data definition in this.h. I hope this helps you fix your problem…
15 Jan, 2009, Jaegar wrote in the 7th comment:
Votes: 0
I found where it was. In board.h the

typedef struct board_data BOARD_DATA;

was below the board_data.

Thanks for the help and insite.
0.0/7