struct "dereferencing pointer to incomplete type"

This is a discussion on struct "dereferencing pointer to incomplete type" within the C Programming forums, part of the General Programming Boards category; I have the following declarations: Code: typedef struct SymbolEntry_tag * SymbolEntry; struct SymbolEntry_tag { Identifier id; Scope scope; SymbolEntry nextInHash; ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    36

    struct "dereferencing pointer to incomplete type"

    I have the following declarations:

    Code:
     
    typedef struct SymbolEntry_tag * SymbolEntry;
    
    struct SymbolEntry_tag {
       Identifier   id;                 
       Scope        scope;          
       SymbolEntry  nextInHash;        
       SymbolEntry  nextInScope;       
       Type		type;
    };
    
    SymbolEntry symbolentry;
    
    (symbolentry->type) = ...  <------
    and i get dereferencing pointer to incomplete type error where the arrow is. Any ideas?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    What is Type?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    36
    Code:
    typedef struct Type_tag * Type;
    
    struct Type_tag {          
       enum {                  
          TYPE_unit,           
          TYPE_bool,           
          TYPE_char,           
          TYPE_int,            
          TYPE_float,          
          TYPE_array,          
          TYPE_ref,            
          TYPE_func,           
          TYPE_id              
       } kind;                 
       union {                 
          struct {             
             int dim;          
             Type type;        
          } t_array;           
          struct {             
             Type type;        
          } t_ref;             
          struct {             
             Type type1;       
             Type type2;       
          } t_func;            
          struct {             
             Identifier id;    
          } t_id;              
       } u;                    
    };

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Is symbolentry pointing to an object?

    [edit]Is your ... a pointer to a valid struct Type_tag object?
    Last edited by Dave_Sinkula; 04-14-2005 at 02:42 PM.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    36
    first of all it is a valid struct Type_tag object. secondly i put the ... in the next line and i get the error on the line where the (symbolentry->type) is

  6. #6
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Well, there is not enough context for me to even attempt to reproduce any similar diagnostic message. I'll quit.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I'll give you one post worth:

    Is Type_tag declared before or after SymbolEntry_tag, or, are they even able to see eachother in scope? An "incomplete type" error means that you're trying to use an object which has not been defined any place. This would be akin to the following:
    Code:
    struct foo
    {
        struct bar *baz;
    };
    
    struct foo f->baz->something = somethingelse;
    Here, we have no idea what "struct bar" contains, because it's not defined anywhere. That's what you've got. Since you've just pasted in random definitions for us, and haven't actually shown us the real file you're working with, this is as good as it's going to get.

    You are trying to use "type", without that structure being available to it in any scope. Declare it before you try to use it, so that it knows what "type" contains.

    Also, in the future, don't replace stuff with "...". It might actually help someone in the future to see what it is you were trying to assign there, rather than just "...".

    Quzah.
    Hope is the first step on the road to disappointment.

  8. #8
    Registered User
    Join Date
    Apr 2003
    Posts
    36
    i m working with six header files and six source files, thats why i couldn't post it all. I was hoping for a short easy answer. it must be a scope thing which i can't sort out.

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Well there you go. You're trying to use a structure whose header you have not included.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. traverse struct using pointer calculus
    By jeanluca in forum C Programming
    Replies: 15
    Last Post: 06-03-2009, 02:18 AM
  2. Assignment HELP!!
    By cprogrammer22 in forum C Programming
    Replies: 35
    Last Post: 01-24-2009, 01:24 PM
  3. Struct Pointer Problems. (Warning: Long Post.)
    By Phoenix940 in forum C Programming
    Replies: 1
    Last Post: 11-30-2008, 09:04 PM
  4. Glib and file manipulation
    By unixOZ in forum Linux Programming
    Replies: 1
    Last Post: 03-22-2004, 08:39 PM
  5. Bi-Directional Linked Lists
    By Thantos in forum C Programming
    Replies: 6
    Last Post: 12-11-2003, 09:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21