Picking apart declarations

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Theese

    Picking apart declarations

    Hello all,

    I've been studying up on declarations (to write a parser for them) and came
    up with a complicated and contrived example. I just want to run it by the
    group to see if I've got it right...

    // dfg is a pointer to a function (taking an int and a reference to a
    // void **) returning a pointer to an array of 6 arrays of 4 pointers to
    // const char.
    char const *(*(*dfg)(int, void **&))[6][4];

    Look about right???

    Thanks!
    Dave


  • Gianni Mariani

    #2
    Re: Picking apart declarations

    Dave Theese wrote:[color=blue]
    > Hello all,
    >
    > I've been studying up on declarations (to write a parser for them) and came
    > up with a complicated and contrived example. I just want to run it by the
    > group to see if I've got it right...
    >
    > // dfg is a pointer to a function (taking an int and a reference to a
    > // void **) returning a pointer to an array of 6 arrays of 4 pointers to
    > // const char.
    > char const *(*(*dfg)(int, void **&))[6][4];
    >
    > Look about right???[/color]

    The trick on reading these things is to start at the variable and read out.

    (*dfg) - pointer to


    (*dfg)(int, void **&) - function

    char const *(*PTR_TO_FUNC)[6][4]; - returning a pointer to an array of
    [6]x[4] pointers to char const.

    Yep - I think you're right.


    Comment

    Working...