www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/15/23:04:46

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Definition of struct for dynamic linked list.
Date: Sun, 15 Mar 1998 19:37:22 -0800
Organization: Alcyone Systems
Lines: 34
Message-ID: <350C9E71.214A1399@alcyone.com>
References: <3507af4d DOT 5302402 AT news DOT manawatu DOT gen DOT nz>
NNTP-Posting-Host: charmaine.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Michael Langton wrote:

> typedef int stype;
> struct nodeS {
>         stype   data;
>         nodeS   *next;
> }
> 
> I'm getting "parse error before 'nodeS'", but not all the time.  It
> sometimes works when I try it in a new program, and other
> circumstances which I'm not quite sure about.
> 
> Can anybody point out why this might be occurring?

The problem is that, in C, the tag of a structure is not legal without
being prefixed by the keyword `struct'.  That is:

    struct S { ... };

    S s; /* this is an error */

You have to reference it with the `struct' tag:

    struct S { ... };

    struct S s; /* this is fine */

-- 
         Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
                       Alcyone Systems / http://www.alcyone.com/max/
  San Jose, California, United States / icbm:+37.20.07/-121.53.38
                                     \
        "I've got the fever for the / flavor of a cracker"
                                   / Ice Cube

- Raw text -


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