This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: error using "struct"
- From: Claudio Bley <bley at cs dot uni-magdeburg dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 8 Jul 2003 00:02:19 +0200
- Subject: Re: error using "struct"
- References: <005501c344cc$4cc8c8b0$f1c8a8c0@fernanda>
On Mon, Jul 07, 2003 at 06:11:14PM -0300, Fernanda Capella wrote:
> Hi!
Hi...
> I'm facing problems compilig a C program that uses struct. I made a very
> simple code to show the error: "parse error before '.' token".
>
> Any help would be very appreciated.
>
> Thanks, Fernanda.
>
>
> -------------------------------------------
> //struct_test.c
>
> typedef struct struct_test{
> unsigned char byte1;
> unsigned char byte2;
> unsigned char byte3;
> }first, second;
>
> first.byte1=0x01;
> second.byte2=0x02;
>
> ----------------------------------------------------
> //The error message:
>
> [root@ root]# gcc -c struct_test.c
> struct_test.c:7: parse error before '.' token
>
Your typedef just creates 2 aliases for your struct "struct_test"
called "first" and "second" ie "first" and "second" are no variables.
first a;
second a;
struct struct_test a;
The above statements are semantically all equivalent. I suppose what
you're trying to do is the following:
typedef struct struct_test {
unsigned char byte1;
unsigned char byte2;
unsigned char byte3; } struct_test;
struct_test first, second;
--
Claudio Bley ASCII ribbon campaign (")
Debian GNU/Linux user - against HTML email X
http://www.cs.uni-magdeburg.de/~bley/ & vCards / \