How to Read this Declaration

Discussion in 'C Programming' started by vaysagekv, Sep 11, 2012.

  1. vaysagekv

    vaysagekv Guest

    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
     
    vaysagekv, Sep 11, 2012
    #1
    1. Advertising

  2. vaysagekv

    Kaz Kylheku Guest

    On 2012-09-11, vaysagekv <> wrote:
    > 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".
     
    Kaz Kylheku, Sep 11, 2012
    #2
    1. Advertising

  3. On 11/09/2012 08:27, vaysagekv wrote:

    > 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
     
    Francois Grieu, Sep 11, 2012
    #3
  4. On 11/09/2012 08:27, vaysagekv wrote:

    > 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
     
    Francois Grieu, Sep 11, 2012
    #4
  5. vaysagekv

    vaysagekv Guest

    On 11/09/12 12:46 PM, Francois Grieu wrote:
    > On 11/09/2012 08:27, vaysagekv wrote:
    >
    >> 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

    Thnaks a lot
     
    vaysagekv, Sep 11, 2012
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Noah
    Replies:
    5
    Views:
    969
  2. Alex Vinokur
    Replies:
    4
    Views:
    604
    Jonathan Turkanis
    Apr 5, 2004
  3. Ovidesvideo
    Replies:
    4
    Views:
    528
    Andrey Tarasevich
    Dec 10, 2004
  4. kelvSYC
    Replies:
    6
    Views:
    7,272
    Richard Herring
    May 17, 2005
  5. Replies:
    4
    Views:
    1,098
    Richard Tobin
    Dec 12, 2006
Loading...

Share This Page