Mail Archives: djgpp/1997/01/13/10:04:59
On 13 Jan 1997, Alaric Dailey wrote:
> ctrlbrk.c:8: warning: passing arg2 of `signal; from incompatable pointer
> type
>
> since it is only a warning when it finishes then runs as I expected it to,
> so now my questions change. Although I am familiar with pointers, I am
> not great with them, so how do I fix the warning.
By looking in the docs and feeding `signal' with arguments it expects.
`signal' needs a function which accepts an int and returns nothing, so
you should make `terminate' to be like so:
void terminate (int signo)
{
fprintf(stderr, "ending function called with signal %d!\n", signo);
exit(0);
}
And also change `ctrlbrk' to be like so:
void ctrlbrk(void (*fptr)(int))
{
signal(SIGINT,fptr);
}
> Second when you change
> the extention and compile it as c++ you get the errors that follows -
>
> ctrlbrk.cc:5: `ftpr' was not declared in this scope
C++ requires that you put the declaration of fptr inside the parentheses;
it doesn't allow K&R syntax. So the above change in `ctrlbrk' should
also solve your problems with C++ (although I didn't actually try this).
You should also get used to declaring your `main' "int main", but that's
another story.
- Raw text -