Message-ID: <37AF8A0F.7FAA@ns.sympatico.ca> From: Klaas Organization: N/A X-Mailer: Mozilla 3.04 (Win95; I) MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp,comp.os.programmer,comp.graphics.algorithms Subject: Re: struct problem References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 56 Date: Mon, 09 Aug 1999 23:10:23 -0300 NNTP-Posting-Host: 142.177.75.52 X-Trace: sapphire.mtt.net 934250997 142.177.75.52 (Mon, 09 Aug 1999 23:09:57 ADT) NNTP-Posting-Date: Mon, 09 Aug 1999 23:09:57 ADT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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 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); }