stm32bootload--typedef void (*fun) (void) Understanding

Source: Internet
Author: User

1. Typdef usage is shown below

1 Char uint8_t; 2  Short int   uint16_t; 3 int     uint32_t;   4 uint8_t i;  // To define a 8-bit unsigned character type variable

2. Pointer function form

1 //defines a function pointer Pfun, pointing to a function with a return type of int, with a parameter of int2 int(*pfun) (int) ; 3 //The pointer level understands that the function's function name is a pointer4 //The pointer points to the first address of the function in memory5 intShiftfun (inta)6 {7    inttemp;8temp =A;9temp<<A;Ten    returnA; One } A intMain () - { -     inttemp; the //assigns the address of the function Shiftfun to the variable pfun -Pfun =Shiftfun;  - //*pfun "is obviously taking the content of the address pointed to by Pfun, of course, is to take out the contents of function Shiftfun (), and then given a parameter of 2.  -temp = (*pfun) (2);  +}

3. typedef return TYPE (* new type) (parameter table)

 1  typedef char  (*ptrfun) (int  );    2  ptrfun pfun;  3  char  glfun ( int  a) {return    ;}  4  void   main ()  5  { 6    pfun = Glfun;  7  (*pfun) (2  );  8 } 

Up to typedef void (*fun) (void);

The function of a typedef is to define a new type of known type, so the return value of the new type (*FUNC) (void) is void.

Defines a new type, which is a function pointer that points to a function parameter of void and the return value is void.

stm32bootload--typedef void (*fun) (void) Understanding

Related Article

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.