Search code examples
c++function-pointerstypedeffunction-declaration

Why parentheses are important in function pointer declaration?


I don't understand why the declaration below is accepted:

typedef void    (*_tStandardDeclaration)(LPVOID);

while the following doesn't:

typedef void    *_tDeclarationWithoutParenthesis(LPVOID);
typedef void*   _tAlternateDeclaration(LPVOID);

I am using MSVC6 (I know it's obsolete and non-standard, but it's needed to maintain a yearly tenth-million revenue system :/ )


Solution

  • The pointer symbol binds to the type by default, so the function pointer needs the parenthesis to indicate that the pointer is actually on the name and not on the return type.