Mail Archives: djgpp/1998/01/28/03:40:40
> Hmm well I was messing around with the allegro readkey command and it
> gave me this starnge errorhere is the code.
>
> {
> int allegro_init();
> int install_keyboard();
>
> printf("think I got it.\n");
> int readkey();
> return(0);
> }
>
> and when its compiling Rhide says there is a parse error before int in
> the readkey line...yet if I place that line somewhere else it doesnt say
> anything..plus it doesnt work...just wonderin.
It is not so strange... this happens because you are confusing
function declaration with function call:
int allegro_init() declares allegro_init as a function returning an
integer,
but does not call it.
In C declaration are correct if they come before every other statement in
the
block. This means that allegro_init and install_keyboard are interpreted
silently as declarations before a statement, while readkey is interpreted
as a declaration between two statement, which is not allowed in C, hence
the
error you get.
if you remove the "int" you will remove *both* the errors :-)
ciao
Giacomo
- Raw text -