Mail Archives: djgpp/1995/08/11/11:14:11
Danny Yoo (dannyyoo AT ix DOT netcom DOT com) wrote:
: I'm having some really strange problems compiling a linked list
: program. Compiling this portion of it:
: #include "stdlib.h"
: #include "conio.h"
: #include "iostream.h"
: #include "string.h"
: #include "ctype.h"
: static int NODECOUNT=0;
: const int ACTIVE=1;
: const int INACTIVE=0;
: struct link {
: struct node *nodeptr;
: char status;
: struct link *next;
: };
: struct node {
: // Node information
: int id;
: char *name;
: struct link *ring;
: };
: // Prototypes
: link *initlink(link *target);
: link *addlink(link *ring);
: node *initnode(node *target);
: void connect(node *element, node *nodes);
: void hook(node *element1, node *element2);
: void shownode(node *source);
: node *setnode(node *target);
: node *findnode(node *target, int number);
: results into strange error messages:
: sphere11.cpp:26: parse error before `*'
: sphere11.cpp:26: `target' was not declared in this scope
: sphere11.cpp:26: warning: ANSI C++ forbids declaration `initlink' with
: no type or storage class
: sphere11.cpp:27: parse error before `*'
: sphere11.cpp:27: `ring' was not declared in this scope
: sphere11.cpp:27: warning: ANSI C++ forbids declaration `addlink' with
: no type or storage class
: ... etc. I see nothing wrong with the code, which compiles fine under
: TC 3.0. The problem seems to be related to the #include files,
: because when I stripped them off the structs caused no problems during
: compilation... I need to use DJGPP because of the memory hogging
: "features" <grin> of a spherical linked list. I'm using v1.2 maint 4
: of DJGPP. Any help would be greatly appreciated, thanks!
The main problem I see is that you are using the variable types node and
link in your prototypes but they aren't defined. Actually the types are
struct node and struct link. If you want to keep your prototypes as they
are try adding (before them)
typedef struct node node;
typedef struct link link;
Not good IMHO because of name confusion, but available.
Jere
- Raw text -