Alex Vinokur said:
How does typedef work for foo2_t?
What can one do with foo2_t?
------ bar.c ------
void foo() {}
typedef void (*foo1_t)();
This means that
foo1_t x;
is a declaration that x is a pointer to a function taking unknown arguments
and returning void.
typedef void foo2_t(); /* How does typedef work here? */
This means that
foo2_t y;
is a declaration that y is a function taking unknown arguments and returning
void.
Because it's a function, it can't be instantiated in the same way an object
can. Nevertheless, this is a useful technique. If the topic cops can just
hold their fire for a second...
typedef LRESULT RJH_MESSAGE_HAN DLER(HWND,
UINT,
WPARAM,
LPARAM);
RJH_MESSAGE_HAN DLER DebuggerCreate;
RJH_MESSAGE_HAN DLER DebuggerDestroy ;
RJH_MESSAGE_HAN DLER DebuggerReset;
RJH_MESSAGE_HAN DLER DebuggerDisplay ;
is valid C, and (arguably) is neater than:
LRESULT DebuggerCreate( HWND, UINT, WPARAM, LPARAM);
LRESULT DebuggerDestroy (HWND, UINT, WPARAM, LPARAM);
LRESULT DebuggerReset(H WND, UINT, WPARAM, LPARAM);
LRESULT DebuggerDisplay (HWND, UINT, WPARAM, LPARAM);
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)