0

I have a script

a.h    
#include b.h    

typedef struct b B;
typedef struct a A;
struct a{
   a   val1;
   b   val2;
}

b.h    
#include a.h    

typedef struct b B;
typedef struct a A;
struct b{
   a   val1;
   b   val2;
}

how can I make this work?
I can create val1 and give him val1.val2=xx but val1.val2.val1=xx or val2.val1=xx it isn't working.

Masoud
  • 8,020
  • 12
  • 62
  • 123
Rhuan Caetano
  • 285
  • 3
  • 9

1 Answers1

1

You're trying to create a struct that contains a copy of itself. That can't work. What you can do is create a pointer to itself:

typedef struct b B;
typedef struct a A;
struct b{
   A   *val1;
   B   *val2;
};
dbush
  • 205,898
  • 23
  • 218
  • 273