i have a struct (T1)
inside the struct (T1) i have function pointer which get a struct (T2) pointer as an argument
the problem is that struct T2 doesn't declared yet,
and i get compiler error.
thanks in advanced for any help
something like this:
// forward declaration
typedef struct T2 T2;
typedef struct _tagT1 {
T2 *t2;
} T1;
thank you very much, i'll check this
I tried this, and it didn't work for me.
what i want to do is:
typedef struct _test1 {
int num1;
void (*PrintNum1)(test1 * ); // <-- this is a pointer to the struct
}test1;
i get the error: Extraneous old-style parameter list.
typedef struct _test1 {
int num1;
void (*PrintNum1)(struct test1 * ); // <-- this is a pointer to the struct
}test1;
thanks for reply.
this also doesn't work.
here is my code (i mentioned in the first post i'm using a function pointer)
typedef struct _test1 {
void (*PrintNum1)(struct test1 *);
}test1;
void test1__PrintNum1 (struct test1 *self);
void test1__PrintNum1 (struct test1 *self)
{
}
void init(void)
{
struct test1 t;
t.PrintNum1 = test1__PrintNum1;
}
In forward reference you have to refer to the tag (_test1) not to the type defined (test1) that must be used in all successive instances:
typedef struct _test1 {
void (*PrintNum1)(struct _test1 *);
}test1;
void test1__PrintNum1 (test1 *self);
void test1__PrintNum1 (test1 *self)
{
}
void init(void)
{
test1 t;
t.PrintNum1 = test1__PrintNum1;
}
thank you very much sir.
it works exactly as i wanted.