What does “typedef void (*Something)()” mean

后端 未结 5 498
星月不相逢
星月不相逢 2020-12-02 14:38

I am trying to understand what this means, the code I am looking at has

in .h

typedef void (*MCB)();
static MCB     m_process;

in .

5条回答
  •  一向
    一向 (楼主)
    2020-12-02 15:15

    The typedef defines MCB as the type of a pointer to a function that takes no arguments, and returns void.

    Note that MCB Modes::m_process = NULL; is C++, not C. Also, in C, the typedef should really be typedef void (*MCB)(void);.

    I'm not sure what you mean by "the memory was freed". You have a static pointer to a function; a function cannot be freed. At most, your pointer has been reset somewhere. Just debug with a memory watch on m_process.

提交回复
热议问题