Re: syntax errror



At about the time of 12/2/2005 1:17 AM, Keith Thompson stated the following:

> Daniel Rudy <spamthis@xxxxxxxxxxxx> writes:
> [snip]
>
>>Personally, I see a couple of problems with this (someone please correct
>>me if I'm wrong).
>>
>>typedef struct ImageT_tag__ {
>> char magicNum[2];
>> int width;
>> int maxGrey'
>> int pixels[ROW][COLUMN];
>>} ImageT;
>>
>>
>>ImageT ImageTvar;
>>
>>fscanf(infile, "%c", &ImageT.magicNum[0]);
>
>
> This fixes the type error from the original code, but it has the same
> problem that it uses ImageT as if it were a variable name, when in
> fact it's a type name. Presumably you meant
>
> fscanf(stdin, "%c", &ImageTvar.magicNum[0]);
>
> It's always a good idea to compile your code before posting it; that
> would have caught both this error and the syntax error in the
> declaration of maxGrey.
>

Yeah, I was dead tired and on my way to bed when I wrote that. I make
no excuse though.

>>Now this brings up a very interesting question in C89. I've actually
>>had code that refused to compile unless I placed an identifier after the
>>struct. Is that part of the standard, or is it just a gcc thing?
>
>
> As far as I know, it's neither. Can you show an example?
>

I stand corrected, it was a warning, but the type name didn't register
properly which caused errors later on. Look at the struct above, but
omit the ImageT_tag__ identifier. I was using gcc at the time.
Something about useless statement.

--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
.