Keil Logo

GENERAL: USING 2 STRUCTS THAT HAVE POINTERS TO EACH OTHER

QUESTION

Is it possible to cross reference two structures with pointers? To do this the compiler must allow declarations of one structure before the second is defined. For example:

struct A {
 struct *bptr;
};

struct B {
 struct *aptr;
};

ANSWER

Yes. This is supported in ANSI C. The following example does compile correctly (with no errors or warnings) under C51 version 5.

struct a
  {
  struct b *ptr;
  };

struct b
  {
  struct a *ptr
  };

Last Reviewed: Monday, May 24, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.