LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-11-2004, 03:37 PM   #1
Nerox
Member
 
Registered: Jul 2004
Location: Spain
Posts: 111

Rep: Reputation: 20
Unintelligible declaration of signal function


Hi, I do not understand the following function declaration:

Code:
void (*signal(int signum, void (*handler)(int)))(int);
I only understand the int signum (the signal to be handled) and void(*handler)(int) (a pointer to a function which returns void and takes int, but...

What does the ending int means?
Why (*signal...) ?

The signal manpage says:
Quote:
signal returns the previous value of the signal handler, or SIG_ERR on error.
So, why is it declared as void?


Thanks In Advance.
 
Old 08-11-2004, 03:47 PM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
This is further down in the man page:
Quote:
If you're confused by the prototype at the top of this
manpage, it may help to see it separated out thus:

typedef void (*sighandler_t)(int);
sighandler_t signal(int signum, sighandler_t handler);
Does that help clear it up?
 
Old 08-11-2004, 03:58 PM   #3
Nerox
Member
 
Registered: Jul 2004
Location: Spain
Posts: 111

Original Poster
Rep: Reputation: 20
So... does it mean that signal function returns a pointer to the function handler which takes one integer?? Am i right??
 
Old 08-11-2004, 04:19 PM   #4
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Yes.
 
Old 08-11-2004, 04:45 PM   #5
Nerox
Member
 
Registered: Jul 2004
Location: Spain
Posts: 111

Original Poster
Rep: Reputation: 20
That's exactly what i want to know.

Thank you ever so much!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
warning: implicit declaration of function liguorir Linux - Software 5 10-22-2012 03:20 PM
implicit declaration of function 'getdelim' MicahCarrick Programming 2 05-02-2005 11:03 AM
Array declaration in class or main function??? redhatrosh Programming 4 03-15-2005 02:13 PM
Arguments in PHP function declaration Parksy Programming 5 07-04-2004 04:22 PM
Problem with function declaration Linh Programming 3 04-26-2004 04:58 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration