What the following line means ?

LPCTSTR SayHello(LPCTSTR artist);

typedef LPCTSTR (CALLBACK* SayHelloType)(LPCTSTR);


What does this two lines means? Can you explain a bit ?
The symbol SayHelloType is a function pointer using the __stdcall calling convention (as opposed to __cdecl) which can be used to call any function with a LPCTSTR argument, and returns a LPCTSTR. It could be used to call the function SayHello(...).

If UNICODE is defined, LPCTSTR resolves to const wchar_t*, and if not - const char*.

Note that the symbol CALLBACK resolves to __stdcall via Windows headers (typedef or #define, I forget).

To understand it, you need to understand both function pointers, and character encodings. If you are having difficulties, those are the topics to which you must turn.

Function pointers have an odd syntax and take some getting used to. The dead give away is always the '*' symbol before the name, and in parentheses, with a return value to the left, and an arguement list to the right.
Last edited on
Topic archived. No new replies allowed.