Re: syntax errror



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.

> 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?

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.