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

  • Home
  • SEARCH
  • 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 7814805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:18:53+00:00 2026-06-02T05:18:53+00:00

I have a problem accessing a char* that is in another struct, heres the

  • 0

I have a problem accessing a char* that is in another struct, heres the code:

User_Network.c:

struct User_Networks_t {
    SocialNetwork network;
};

typedef struct User_Networks_t* User_Networks;


void aaa(User_Networks u1)
{
    u1->network->Name = "test";  /// ERROR: dereferencing pointer to incomplete type 
}

Here is what I have in the SocialNetwork.h:

typedef struct SocialNetwork_t* SocialNetwork;

the struct that is in the SocialNetwork.c:

struct SocialNetwork_t {
    char *Name;
};

Why am I getting that error?

  • 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-06-02T05:18:55+00:00Added an answer on June 2, 2026 at 5:18 am

    When you define your struct SocialNetwork_t in the implementation file SocialNetwork.c, the compiler can not know about the contents of the struct when it is compiling User_Network.c, if you only use #include <SocialNetwork.h there. The compiler parses the header file SocialNetwork.h and knows that it should find the definition of the struct SocialNetwork_t later on, but doesn’t encounter that definition when compiling the dereference in void aaa(...). So, put the complete struct definition into SocialNetwork.h.

    [update]
    I’ll elaborate a little bit more on that answer. I guess your file User_Network.c looks like this:

    #include "SocialNetwork.h"
    struct User_Networks_t {
        SocialNetwork network;
    };
    
    typedef struct User_Networks_t* User_Networks;
    
    
    void aaa(User_Networks u1)
    {
        u1->network->Name = "test";  /// ERROR: dereferencing pointer to incomplete type 
    }
    

    When your compiler compiles this, the preprocessor substitutes `#include “SocialNetwork.h” with the content of that file, which gives you:

    /* START content from the included file */
    typedef struct SocialNetwork_t* SocialNetwork;
    /* END */
    struct User_Networks_t {
        SocialNetwork network;
    };
    
    typedef struct User_Networks_t* User_Networks;
    
    
    void aaa(User_Networks u1)
    {
        u1->network->Name = "test";  /// The struct SocialNetwork is not defined here
    }
    

    This will be the complete file when the compiler starts the actual compilation. So, when you try to access the Name field from struct SocialNetwork, the compiler didn’t see the struct but only the typedef of a pointer type. Hence it can not know to which type you are actually referring.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have problem with libhid . i found that there 2 way 4 accessing
I have a problem accessing the 'event' in Firefox. The following code works fine
We have a problem in accessing content on a mapped network drive. We have
I have a problem accessing OpenAM SVN repository using Subclipse and was hoping that
I have a problem with accessing the graph API through my android application that
I have a problem accessing JSON data. I'm new to JSON and jquery so
I am having a problem accessing the ViewData object through javascript. I have set
I have problem with fancybox. I want to write a function that will run
I have problem with accessing Facebook graph. I am using a Greasemonkey script. When
I'm quite new to JS and jQuery. I have a problem accessing the properties

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.