typedef void (*pfunction) (void); it's especially good for beginners to learn.

Source: Internet
Author: User
Just saw on the internet, explain the special good, suitable for beginners to learn, master please ignore ...
Turn from: http://blog.csdn.net/zyboy2000/article/details/4202349

(* (Void (*) ()) 0) () equivalent (void (*) ()) 0 ()----reason function is a function-to-pointer way, &fun, fun, *fun, **fun are all the same

Hardware address jumps to 0
(* (Void (*) ()) 0) ();

Preliminary knowledge
Float (*h) ();
Indicates that H is a pointer to a function of the float type of the return value
(Float (*) ())
A type converter that represents a pointer to a function with a float type of return value


Assuming FP is a function pointer, then how to invoke the function that FP points to, the method is invoked as follows:
(*FP) ();

According to People's habitual thinking, then we can write
(*0) ();

The upper type cannot take effect because the operator * must have a pointer for the operand, and the pointer must also be a function pointer. So we have to cast 0 to a function pointer (a pointer to a function with a return value of type void).

Assuming that FP is a float pointer, declare the following
float * FP;

Cast 0 to a float pointer (take the variable FP off)
(float *) 0;

Similar:
Assuming FP is a pointer to a function with a function pointer of type void, it is declared as follows:
void (*FP) ();

Cast 0 to the function pointer (variable FP can be removed)
(Void (*) ()) 0

Finally use (void (*) ()) 0 instead of FP to get the use of the call
(* (Void (*) ()) 0) ();




Use typedef to simplify function pointers
For example:
typedef char * string;

String test= "Hello";

Similar
typedef void (*FUNC) (); So func represents the type of a function pointer

(* (func) 0) ();


Example
Method One:
typedef void (*pfunction) (void);

void Fmi_jump (void)
{
Pfunction Jump;
Jump= (pfunction) (0x80000);
Jump ();

}

Method Two:
((Void (code *) (void)) 0xf400) ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.