A slightly more complicated function pointer declaration

Discussion in 'C Programming' started by Tobias Oed, Jul 10, 2003.

  1. Tobias Oed

    Tobias Oed Guest

    Jason wrote:

    > char * const * (*fn)(void);
    >
    > Seems rarther confusing to me, becuase of the way const can be used, like
    > this:
    >
    > const char * a; /* pointer to const char */
    > char const * a; /* pointer to const char */
    > char * const a; /* const pointer to char */
    >
    > I would guess that function declaration means this:
    >
    > A pointer to a function returning a pointer to a const pointer to a char.
    > Is there a good way of reading things such as this?


    When I am tired I use cdecl:

    qcd:~$ cdecl
    Type `help' or `?' for help
    cdecl> explain char * const * (*fn)(void);
    declare fn as pointer to function (void) returning pointer to const pointer
    to char
    cdecl>

    Tobias.

    --
    unix http://www.faqs.org/faqs/by-newsgroup/comp/comp.unix.programmer.html
    clc http://www.eskimo.com/~scs/C-faq/top.html
    fclc (french): http://www.isty-info.uvsq.fr/~rumeau/fclc/
    Tobias Oed, Jul 10, 2003
    #1
    1. Advertising

  2. Tobias Oed

    Jason Guest

    char * const * (*fn)(void);

    Seems rarther confusing to me, becuase of the way const can be used, like
    this:

    const char * a; /* pointer to const char */
    char const * a; /* pointer to const char */
    char * const a; /* const pointer to char */

    I would guess that function declaration means this:

    A pointer to a function returning a pointer to a const pointer to a char. Is
    there a good way of reading things such as this?
    Jason, Jul 10, 2003
    #2
    1. Advertising

  3. Tobias Oed

    Jason Guest

    "Jason" <@> wrote in message news:3f0ddabc@shknews01...
    > char * const * (*fn)(void);
    >
    > Seems rarther confusing to me, becuase of the way const can be used, like
    > this:
    >
    > const char * a; /* pointer to const char */
    > char const * a; /* pointer to const char */
    > char * const a; /* const pointer to char */
    >
    > I would guess that function declaration means this:
    >
    > A pointer to a function returning a pointer to a const pointer to a char.

    Is
    > there a good way of reading things such as this?
    >
    >


    Any hints?
    Jason, Jul 12, 2003
    #3
  4. Tobias Oed

    Jason Guest

    "Jason" <@> wrote in message news:3f0fd299@shknews01...
    ....
    > Any hints?

    ....

    Sorry, newsfeed very slow.
    Jason, Jul 12, 2003
    #4
    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. Ovidesvideo
    Replies:
    4
    Views:
    483
    Andrey Tarasevich
    Dec 10, 2004
  2. Replies:
    4
    Views:
    1,052
    Richard Tobin
    Dec 12, 2006
  3. Bolin
    Replies:
    4
    Views:
    401
  4. Replies:
    2
    Views:
    469
    Dan Andrews
    Jun 16, 2007
  5. asit

    complicated declaration

    asit, Mar 13, 2008, in forum: C Programming
    Replies:
    3
    Views:
    338
    Ben Bacarisse
    Mar 13, 2008
Loading...

Share This Page