Mail Archives: djgpp/1998/12/21/20:36:51
On Wed, 09 Dec 1998 11:16:47 GMT, horst DOT kraemer AT snafu DOT de (Horst
Kraemer) wrote:
>On Wed, 09 Dec 1998 02:36:35 GMT, shaka AT innotts DOT co DOT uk (Shaka Zulu)
>wrote:
>
>> Hi
>> using djgcc 2.8.1, the following won't compile.
>>
>> system(const char *command)
>> {
>> char buf[4];
>> extern sigint();
>>
>> signal(SIGINT, SIG_IGN);
>> write(4, command, strlen(command)+1);
>> read(5, buf, 1);
>> signal(SIGINT, sigint); \* error line *\
>> return(buf[0]<<8);
>> }
>> why does sigint produce the following error ?
>>
>> warning: passing arg 2 of `signal' from incompatible pointer type
>>
>> my trusty c book state if a function address is used the specified
>> function is executed.
>
>The problem is that your declaration extern sigint(); declares
>
> int sigint();
>
>i.e. a function returning an int and taking an unspecified number of
>parameters, while the second parameter and the return value of
>signal() are declared in <signal.h> as
>
>"pointer to function returning nothing and taking an int parameter".
>
>With a typedef
>
> typedef void (*pSighandler)(int);
>
>this prototype reads
>
> pSighandler signal(int,pSighandler);
>
>Without typedef the prototype of 'signal' may look a little bit
>confusing
>
> void (*signal(int,void (*)(int)))(int);
>
>Thus with the declaration
>
> extern void sigint(int);
>
>you would declare a correct signal handler type required by the
>signal() prototype and your code should compile without warning.
>
>Regards
>Horst
tried it and it works ,
just need to see if it links
once i,ve sorted the rest of the errors ,
by the way it isn't my code it's the
Embeddable Common Lisp implementation.(ecl026.zip).
Thanx
Shaka
- Raw text -