Mail Archives: djgpp/1997/09/01/05:34:33
Mark Augustyn wrote:
> I hate to ask a dumb question but is this the appropriate way to declare
> a struct:
>
> struct cell {
> int terrain;
> BITMAP *tile;
> };
>
> It seems simple enough, however, I get the following error when I
> declare a variable to be of type cell:
> Line 16:
> cell map;
>
> test4.c:16: `cell' undeclared (first use this function)
>
> If I substitute class for struct I get the following as well:
> test4.c:7: parse error before `cell'
> test4.c:7: syntax error before `{'
> test4.c:10: parse error before `}'
>
oddly enough C is not C++. even stranger than that is the fact that gcc
assumes files with extension .c contain C source. in C, you need to say:
struct cell map;
to declare a variable of type struct cell. of course, you can define your
struct and a new data type:
typedef struct cell {
int terrain;
BITMAP *tile;
} cell;
then you can use the declaration:
cell map;
> What am I missing? Do I need to include something to use structs and
> classes?
if you accidentally gave your file a .c extension, change the extansion to
.cc. if you are trying to write C, you will need to stay within the
language.
-- Sinan
- Raw text -