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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:07:42+00:00 2026-06-15T00:07:42+00:00

So im getting a Line 51: error: dereferencing pointer to incomplete type when running

  • 0

So im getting a “Line 51: error: dereferencing pointer to incomplete type” when running this:

int main(void)
{
  Tree * testTree;

  testADT * data1;

  testTree = createTree(compare,destroy);

  data1 = malloc(sizeof(testADT));

  data1->val = 10;

  /* Line 51 */ addToTree(testTree,testTree->root,data1);

  destroyBinTree(testTree);

  return(0);
}

my addToTreeFunction:

TreeNode * addToTree(Tree * theTree,TreeNode * theTreeNode, TreeDataTypePtr data)
{
TreeNode * newNode;
if(isEmpty(theTree))
{
    newNode = malloc(sizeof(TreeNode));
    newNode->height = 0;
    newNode->data = data;

    theTree->root = newNode;
    return theTree->root;
}else{
    if(theTree->compare(theTreeNode->data,data) == 1) /* shows root data is smaller */
    {
        theTreeNode->right = addToTree(theTree,theTreeNode->right,data);
    }else 
    if(theTree->compare(theTreeNode->data,data) == 0) /* shows root data is larger */
    {
        theTreeNode->left = addToTree(theTree,theTreeNode->left,data);
    }
}
return theTreeNode;
}

my typedefs and structs:

struct tADT{
int val;
};

typedef struct tADT testADT;

typedef void * TreeDataTypePtr;

Could anyone provide some insight into whats going on? Thanks-in advance!

Edit: This is in my module (.c)

struct AvlNode{
void * data;
struct AvlNode * left;
struct AvlNode * right;
int height;
};


struct AvlTree{
int (*compare) (TreeDataTypePtr data1, TreeDataTypePtr data2);
void (*destroy) (TreeDataTypePtr data);
struct AvlNode * root;
};

this is in the header (.h)

struct AvlTreeNode;
struct AvlTree;

typedef struct AvlTree Tree;
typedef struct AvlNode TreeNode;
typedef void * TreeDataTypePtr;

Problem fixed by defining all structs/typedefs in header:

typedef struct AvlTree Tree;
typedef struct AvlNode TreeNode;
typedef void * TreeDataTypePtr;

struct AvlNode{
void * data;
struct AvlNode * left;
struct AvlNode * right;
int height;
};


struct AvlTree{
int (*compare) (TreeDataTypePtr data1, TreeDataTypePtr data2);
void (*destroy) (TreeDataTypePtr data);
struct AvlNode * root;
};
  • 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-15T00:07:43+00:00Added an answer on June 15, 2026 at 12:07 am

    Are you defining “Tree” somewhere in one of your header files? Can line 51 of the failing module see that header?

    You must define “Tree” 🙂

    ===================== ADDENDUM ====================

    Thank you for updating your post with your “definition” of Tree:

    // .h file
    struct AvlTreeNode;
    struct AvlTree;
    typedef struct AvlTree Tree;
    ...
    

    But the fact remains – these are both “incomplete types”.

    You say you defined AvlTree and AvlTreeNode “in your module (.c)”.

    Q: Which .c translation unit?

    Q: Is it defined in that translation unit before you try to use it?

    Q: Is it used in any other translation unit?

    Q: Why the duplicate/redundant/confusing typedef aliases?

    Q: Why, for heaven’s sake, don’t you just define it in your .h file?

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

Sidebar

Related Questions

I am getting ERROR when I am running this program at the line static
I am getting the object reference error in this line: emp[count].emp_id = int.Parse(parts[0]); in
I'm getting a compiler error for this line: Collections.sort(terms, new QuerySorter_TFmaxIDF(myInteger)); My customized Comparator
I am getting an error at the line void operation when I compile, because
I keep getting this error in the $('#savetickets-list') line. I want to dynamically add
I keep getting an expected identifier error at this line in my code =/
I am getting an error Incorrect syntax near ',' for this query on line
Hi i'm getting a (Line 7) Parse error in input = for this which
Hi i am getting error on this line. Its working in local. I just
I keep getting this error: line 4, in timesTwo IndexError: list index out 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.