loop in declaration

Discussion in 'C Programming' started by Frédéric Kpama, Dec 24, 2011.

  1. Hi all,

    I have a pretty simple issue but I can't find how to get out of it.

    let's say I have the following 3 statements to include in my code :

    -----
    typedef long FunctionPtr(SOME_TYPE *);

    -----

    typedef struct {
    FunctionPtr * foo;
    } VTBL_TYPE;

    -----

    typedef struct {
    VTBL_TYPE * bar;
    } SOME_TYPE;

    -----

    I can't find a way to declare those three elements without the
    compiler complaining.

    any idea?

    thanks a lot.
    Frédéric Kpama, Dec 24, 2011
    #1
    1. Advertising

  2. Frédéric Kpama

    Seebs Guest

    On 2011-12-24, Fr?d?ric Kpama <> wrote:
    > I have a pretty simple issue but I can't find how to get out of it.


    Forward declaration.

    struct WILL_BE_A_TYPE;
    > typedef struct {
    > struct WILL_BE_A_TYPE * bar;
    > } SOME_TYPE;
    > typedef long FunctionPtr(SOME_TYPE *);
    > typedef struct WILL_BE_A_TYPE {
    > FunctionPtr * foo;
    > } VTBL_TYPE;


    You can declare an incomplete type, and you can use pointers to it.

    -s
    --
    Copyright 2011, all wrongs reversed. Peter Seebach /
    http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
    http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
    I am not speaking for my employer, although they do rent some of my opinions.
    Seebs, Dec 24, 2011
    #2
    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:
    950
  2. Alex Vinokur
    Replies:
    4
    Views:
    581
    Jonathan Turkanis
    Apr 5, 2004
  3. Ovidesvideo
    Replies:
    4
    Views:
    499
    Andrey Tarasevich
    Dec 10, 2004
  4. kelvSYC
    Replies:
    6
    Views:
    7,221
    Richard Herring
    May 17, 2005
  5. Isaac Won
    Replies:
    9
    Views:
    364
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page