www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/13/09:03:40

From: alaric AT oasis DOT novia DOT net (Alaric Dailey)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: catching a CTRL C / Just for Eli and DJ Delorie
Date: 13 Jan 1997 06:44:45 GMT
Organization: Novia Internetworking <> 28.8kbps dialup; 402/390-2NET
Lines: 55
Message-ID: <5bclkt$idc@nntp.novia.net>
References: <5b9r78$h1f AT nntp DOT novia DOT net> <5bb23s$6oq AT nntp DOT novia DOT net> <5bcg61$eep AT nntp DOT novia DOT net>
NNTP-Posting-Host: oasis.novia.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Alaric Dailey (alaric AT oasis DOT novia DOT net) wrote:
OK here is what I have changed my code to -

#include <signal.h>
#include <stdio.h>

void ctrlbrk(fptr)
   int (*fptr)();
{
   signal(SIGINT,fptr);
}

int terminate()
{
	puts("ending function called!");
	exit(0);
}
main()
{
	ctrlbrk(terminate);
	
	while(1)
		puts("I am running on and on!");
}


this compiles with the following  warning

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. 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
ctrlbrk.cc:6: parse error before `int'
ctrlbrk.cc:7: parse error before `{'
ctrlbrk.cc: In function `int main()':
ctrlbrk.cc:18: warning implicit declaration of function `int ctrlbrk(...)'


why is this?



-- 
####################################################
We go left, right, left, right, left-
They're left in the right again.
We go right, left, right, left, right-
We've no rights left anymore.

		-Martin Walkyier (Skyclad)

- Raw text -


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