delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/11/10:09:09

Message-ID: <37B01973.6C893957@aol.com>
Date: Tue, 10 Aug 1999 08:22:16 -0400
From: Chris Russ <jcr6 AT aol DOT com>
Organization: Reindeer Games, Inc.
X-Mailer: Mozilla 4.5 (Macintosh; U; PPC)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp,comp.graphics.algorithms
Subject: Re: struct problem
References: <A7083B60FEDED7E0 DOT 7F2CBC07CD9B5AB8 DOT 019CE2E485CE12C4 AT lp DOT airnews DOT net> <37AF8A0F DOT 7FAA AT ns DOT sympatico DOT ca>
NNTP-Posting-Host: 32.100.213.78
X-Trace: 10 Aug 1999 12:25:17 GMT, 32.100.213.78
Lines: 63
X-Notice: Items posted that violate the IBM.NET Acceptable Use Policy
X-Notice: should be reported to postmaster AT ibm DOT net
X-Complaints-To: postmaster AT ibm DOT net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

It sounds like he's run across problems with the version of YACC in his
compiler... Do you think the p000 is turning into an ascii null?  Shades of
octal...

Klaas wrote:

> Matthew Heyman wrote:
> >
> > All right....   I have a struct declared like this in a header file.
> >
> > typedef struct
> > {
> > int x; // x
> > int y; // y
> > int z; // z
> > } vert_3d;
> >
> > Within the main .cpp file I have this declaration as a global.
> >
> > vert_3d p000;
> > p000.x = 0;
> > p000.y = 10;
> > p000.z = 20;
> >
> > After compiling the program I get an error that says there is a syntax
> > error in this line and every one after.
> >
> > p000.x = 0;  //syntax error before '.'
> >
> > This error happens on every single declaration of the program in every
> > single struct I use.  The program gives no problems with the struct
> > declarations, only on the variable assignments themselves.
> >
> > Thanks for any help.
>
> Is this entire code snippet global?  You can't assign variables outside
> of a function - you can only declare vars (with the option to
> initalize).
>
> Try this micro-program.  If it doesn't work, then there is something
> worng with your compiler:
>
> // ------------- Struct test
> #include <stdio.h>
>
> typedef struct {
>     int x,y,z;
> } vert_3d;
>
> vert_3d p000;
>
> void main() {
>
>    p000.x=0;
>    p000.y=10;
>    p000.z=20;
>
>    printf("%d %d %d\n",p000.x,p000.y,p000.z);
>
>    exit(0);
>
>    }

- Raw text -


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