Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6760479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:04:08+00:00 2026-05-26T14:04:08+00:00

If I will code some thing like following: typedef struct { int a; PTR1

  • 0

If I will code some thing like following:

typedef struct {
    int a;
    PTR1 bpointer;
} *PTR2;

typedef struct {
    int b;
    PTR2 cpointer;
} *PTR1;

I am defining PTR1 after PTR2,but using if using it first then it will be may be compile time or runtime error. So how can I avoid any such error and use two referential structures? I think same is thing that we do in two interdependent classes. So is it possible that it will not show any error because we are just defining them at this time and at calling these both are already defined? Confuse a little bit.

I really appreciate your time to see my question and you effort.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:04:09+00:00Added an answer on May 26, 2026 at 2:04 pm

    The first step is to get rid of the typedefs and use struct tags. Then you can forward-declare the struct tags, and make the typedefs separately if you still want to use them. Note that it’s considered very very bad style to use typedef to define pointer-to-struct types, especially if there’s no way to refer to the pointed-to type when you’re finished.

    struct struct1;
    struct struct2;
    
    struct struct2 {
        int a;
        struct struct1 *bpointer;
    };
    
    struct struct1 {
        int b;
        struct struct2 *cpointer;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Confusing title, hopefully some code will clarify: struct MyNestedType { void func(); }; struct
Please consider the following piece of code: int main() { typedef boost::ptr_vector<int> ptr_vector; ptr_vector
I have some code that will be accessed from two threads: class Timer{ public:
I've got some code that will generically get all Controls in a form and
I currently have some code that will produce a crash dump when my application
Does anyone have some code that will take a TimeZoneInfo field from .NET and
I need to run some code that will fetch some configuration values from the
I've been asked to implement some code that will update a row in a
I am trying to find some code which will help me to find out
I'm looking for a library that will disassemble x86 code into some sort of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.