www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/08/11/11:14:11

Xref: news-dnh.mv.net comp.os.msdos.djgpp:1471
Newsgroups: comp.os.msdos.djgpp
Path: news-dnh.mv.net!mv!news.sprintlink.net!noc.netcom.net!ix.netcom.com!netcom.com!mictali
From: mictali AT netcom DOT com (Jere McDevitt)
Subject: Re: Weird problem with structs...
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
References: <40bhfo$8k8 AT ixnews2 DOT ix DOT netcom DOT com>
Date: Thu, 10 Aug 1995 16:19:30 GMT
Lines: 63
Sender: mictali AT netcom17 DOT netcom DOT com
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019