How to Read this Declaration

V

vaysagekv

Hi,
I have seen a declaration like this in HTMLTidy source code

typedef void(TIDY_CALL *) TidyFree (void *buf)

Can I read it like TidyFree is a typedef to a function taking void
pointer and returning TIDY_CALL pointer casted to void ..Am I wrong.If
Wrong please tell me correct way to read it.

Thanks in advance
Vaysage
 
K

Kaz Kylheku

Hi,
I have seen a declaration like this in HTMLTidy source code

typedef void(TIDY_CALL *) TidyFree (void *buf)

Taken at face value (i.e. TidyFree is not a sneaky macro which
produces suitable tokens to make this work), it is not valid C syntax.
Can I read it like TidyFree is a typedef to a function taking void
pointer and returning TIDY_CALL pointer casted to void ..Am I wrong.If
Wrong please tell me correct way to read it.

The correct way to read it is "syntax error".
 
F

Francois Grieu

I have seen a declaration like this in HTMLTidy source code

typedef void(TIDY_CALL *) TidyFree (void *buf)

http://tidy.sourceforge.net/docs/api/tidy_8h-source.html
actually contains:

typedef void (TIDY_CALL *TidyFree)( void* buf );
Can I read it like TidyFree is a typedef to a function taking void
pointer and returning TIDY_CALL pointer casted to void ..Am I wrong.
If wrong please tell me correct way to read it.

TidyFree is the type for a pointer to a function accepting a pointer
to void as input, and returning no output.

Francois Grieu
 
F

Francois Grieu

I have seen a declaration like this in HTMLTidy source code

typedef void(TIDY_CALL *) TidyFree (void *buf)

http://tidy.sourceforge.net/docs/api/tidy_8h-source.html
actually contains:

typedef void (TIDY_CALL *TidyFree)( void* buf );
Can I read it like TidyFree is a typedef to a function taking void
pointer and returning TIDY_CALL pointer casted to void ..Am I wrong.
If wrong please tell me correct way to read it.

TidyFree is the type for a pointer to a function accepting a pointer
to void as input, and returning no output.
TIDY_CALL is meant to add attributes describing calling conventions
(e.g. fastcall, stdcall, pascal) that are not part of C.

Francois Grieu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top