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 8708067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:01:42+00:00 2026-06-13T04:01:42+00:00

I defined two types in my code. typedef struct Project Project; typedef struct Worker{

  • 0

I defined two types in my code.

typedef struct Project Project;

typedef struct Worker{
  Project projects[10];
}Worker;

struct Project{
 Worker member[30];
}

The compilation process is throwing the following error:

array type has incomplete element type

I think is because of the circular reference, when the compiler is trying to allocate space to the array it does not know the type Project, and the same thing will happen if I change the definition order of the types.
Am I right about the problem? And most important, how can I solve this problem?

  • 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-13T04:01:43+00:00Added an answer on June 13, 2026 at 4:01 am

    You’re correct. Your Worker struct contains the member of type Project by value. In order for the compiler to construct the Worker objects correctly it needs to know it size. This means it needs to have the complete definition of Project type – and in your code it’s defined only a few lines later.
    You can go around this by using by having reference/pointer to a Project members in Worker struct and using forward declaration to announce it so the compiler will know it’s a known type (the problem above is avoided since size of a pointer is independent of type it points to thus the compiler doesn’t need the full type definition).

    Something like this:

    struct Project;  //forward declaration of Project type
    typedef struct Worker{
      Project *projects[10];
    } Worker;
    
    struct Project{
      Worker member[30];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code, I defined two class named Father and Son, and create
Given the following two defined routes: routes.MapRoute(name: CityCategoryPage, url: {city}-{state}/{categoryName}/__c/, defaults: new { controller
I have defined the following two functions test <- function(t) { return( (0.5*eta^2/theta)*(1-exp(-2*theta*t)) )
For convenience, I'd like to be able to cast between two types defined in
I have two objects, each with locally defined types, and I want to determine
I have a lot of code in a big project that has two general
I have two user defined collection types. The first type has the columns: CREATE
When I try to run the following code (two separated assemblies) ClassLibrary.cs public interface
I have defined two module types and two modules module type FOO = sig
if I have two classes, and have defined an explicit type conversion between them,

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.