By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,379 Members | 1,602 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,379 IT Pros & Developers. It's quick & easy.

(*(void(*)())0)();

P: n/a
Can any one explain the function prototype -

( * (void ( * ) ( ) ) 0 ) ( );

Dec 29 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Ganga 写道:
Can any one explain the function prototype -

( * (void ( * ) ( ) ) 0 ) ( );


typedef void (*function_ptr) ();
// function_ptr is a pointer to functions without parameter and return
value

function_ptr pZero = (function_ptr) 0;
// convert 0 to function_ptr

(*pZero)();
// call the function which is pointed by pZero
// that is, call the function whose address is 0.

Dec 29 '05 #2

P: n/a
I understand that statement function_ptr pZero = (function_ptr) 0;
initializes the pointer to 0 just the way non-function pointers are
initialized to NULL.

But wont a call using zero initialized function pointer as in
(*pZero)() cause program to crash?

Dec 29 '05 #3

P: n/a

an*************@gmail.com 写道:
I understand that statement function_ptr pZero = (function_ptr) 0;
initializes the pointer to 0 just the way non-function pointers are
initialized to NULL.

But wont a call using zero initialized function pointer as in
(*pZero)() cause program to crash?


Yes. I cannot remember it exactly, but I think I saw it in <<C Traps
and Pitfalls>>.

The author take this example to show how the function pointer works.
And the example came from a real project, in which a routine at
*ADDRESS 0*
needs be called when the system startup. However, the example is very
special.

Dec 29 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.