www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/28/03:40:40

From: G DOT DegliEsposti AT ads DOT it
To: djgpp AT delorie DOT com
Message-ID: <C125659A.002F1776.00@vega.ads.it>
Date: Wed, 28 Jan 1998 09:39:45 +0100
Subject: Re: readkey()
Mime-Version: 1.0



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


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019