loop in declaration

F

Frédéric Kpama

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.
 
S

Seebs

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
 

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,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top