473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Some complex function prototypes like signal()

Hello,

I'm confused by some complex function prototypes. Would you please
explain those to me in detail with C language syntax itself with your
rich knowledge & experiences. Thank you.
1. The prototype of function signal in signal.h:

void (*signal(int sig, void (*func)(int)))(int);

it's some complex to me. Please explain the C language syntax used to
make up this complex prototype.

2. And I saw another function prototype:

void interrupt (*oldhandler)();

-Is it legal?

-If it's a right prototype, what does identifier "interrupt" mean?
Should it be a type qualifier?

Thanks

---
lovecreatesbeauty

Nov 14 '05 #1
2 1882

lovecreatesbeauty wrote:
I'm confused by some complex function prototypes.
"The C Programming Language" has a good section on this subject. They
provide source for a program that translates these type definitions
into english.
void (*signal(int sig, void (*func)(int)))(int);
You can simplify this:

/* Pointer to a function that takes an int and returns nothing. */
typedef void (*SIGNAL_HANDLER)(int);

/* Simplified signal prototype. */
SIGNAL_HANDLER signal( int signal, SIGNAL_HANDLER handler );
void interrupt (*oldhandler)();

This is a pointer to a function which returns nothing.

Nov 14 '05 #2
al.h:

void (*signal(int sig, void (*func)(int)))(int);

it's some complex to me. Please explain the C language syntax used to
make up this complex prototype.


The return type for signal is a function pointer that, when called takes
one int argument.

func is a function pointer that takes one int argument.

For more about function pointers, see http://www.newty.de/fpt/index.html

Jon
----
Learn to program using Linux assembly language
http://www.cafeshops.com/bartlettpublish.8640017
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: shan_rish | last post by:
I gather from this group's posts that there is no need of function prototypes if the function is "seen" before it is called. (i.e)the function should be defined before the main(). But in the...
9
by: Grumble | last post by:
Hello everyone, I've come across some strange code. Here it is, stripped down: int main(void) { int *foo; int *bar(); foo = bar(0); return 0;
2
by: None | last post by:
Hello, 1. The prototype of function signal in signal.h: void (*signal(int sig, void (*func)(int)))(int); is some complex to me. Would you please explain it to me in detail with the C...
73
by: Steph Barklay | last post by:
Hi, I'm currently taking a data structures course in C, and my teacher said that function prototypes are not allowed in any of our code. He also said that no professional programmers use function...
6
by: Syren Baran | last post by:
Hi, is it possible to write two functions which both require a function as an argument and both being able to use the other function as an argument? Afaik the address of a function is not known...
0
by: savanior | last post by:
I'm working with some piece of code where I need to do marshalling. But, the problem is that, I want a user of my system to give a path of dll alongwith its name. And my system will load that Dll at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.