This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

"symbol (...) redeclared with incompatible type" compiler bug?

Other Parts Discussed in Thread: CC3200

Hello,

I'm struggling with this error for a few days now and it seems to me to be a bug. I'm trying to compile Zlib to a CC3200 LaunchPad so I've downloaded it and defined as #define Z_SOLO which eliminates use of external libraries. At first place it compiles fine. Using the inflate() function also goes fine because it only requires a few source files of the library. However, when using deflate() function I need to include a few more files and then I get these errors:

Description    Resource    Path    Location    Type
#10192 Failed linktime optimization    CC3200_HTTP_Server             C/C++ Problem
gmake: *** [CC3200_HTTP_Server.out] Error 1    CC3200_HTTP_Server             C/C++ Problem
gmake: Target 'all' not remade because of errors.    CC3200_HTTP_Server             C/C++ Problem
symbol "_tr_align" redeclared with incompatible type:    CC3200_HTTP_Server             C/C++ Problem
symbol "_tr_flush_bits" redeclared with incompatible type:    CC3200_HTTP_Server             C/C++ Problem
symbol "_tr_flush_block" redeclared with incompatible type:    CC3200_HTTP_Server             C/C++ Problem
symbol "_tr_init" redeclared with incompatible type:    CC3200_HTTP_Server             C/C++ Problem
symbol "_tr_stored_block" redeclared with incompatible type:    CC3200_HTTP_Server             C/C++ Problem

It's finding incompatible definitions between trees.c file and deflate.h. So apparently deflate.c and trees.c both include deflate.h.

-in trees.c there are the functions imlpementations (include deflate.h)

-in deflate.h there are the functions prototype

-in deflate.c it only uses those functions (include deflate.h)

Looking at the error description I found out the function definition is striclty the same:

error: symbol "_tr_align" redeclared with incompatible type:
   "void(deflate_state *)"
   in "C:/Users/Felipe Ribas/TI_Workspace/Zlib/trees.c" at line 892 and:
   "void(deflate_state *)"
   in "C:\Users\Felipe Ribas\TI_Workspace\Zlib\deflate.h" at line 302)

and the same goes for the other functions. I though it was a macro problem but I generated the pp files.

deflate.pp:

void  _tr_init (deflate_state *s);
int  _tr_tally (deflate_state *s, unsigned dist, unsigned lc);
void  _tr_flush_block (deflate_state *s, charf *buf, ulg stored_len, int last);
void  _tr_flush_bits (deflate_state *s);
void  _tr_align (deflate_state *s);
void  _tr_stored_block (deflate_state *s, charf *buf, ulg stored_len, int last);

trees.pp:

void  _tr_init (deflate_state *s);
int  _tr_tally (deflate_state *s, unsigned dist, unsigned lc);
void  _tr_flush_block (deflate_state *s, charf *buf, ulg stored_len, int last);
void  _tr_flush_bits (deflate_state *s);
void  _tr_align (deflate_state *s);
void  _tr_stored_block (deflate_state *s, charf *buf, ulg stored_len, int last);

void  _tr_init(s)
    deflate_state *s;
{ 
...

Then I ran a few tests declaring the function without the S parameter and it was fine. Only when using deflate_state * s the problem would appear. Then I thought maybe the structure was being declared differently so I checked the pp files again:

trees.pp

typedef struct internal_state {
    z_streamp strm;       
    int   status;         
    Bytef *pending_buf;   
    ulg   pending_buf_size;  
    Bytef *pending_out;   
    uInt   pending;       
    int   wrap;           
    gz_headerp  gzhead;   
    uInt   gzindex;       
    Byte  method;         
    int   last_flush;     
    uInt  w_size;         
    uInt  w_bits;         
    uInt  w_mask;         
    Bytef *window;
    ulg window_size;
    Posf *prev;
    Posf *head;  
    uInt  ins_h;           
    uInt  hash_size;       
    uInt  hash_bits;       
    uInt  hash_mask;       
    uInt  hash_shift;
    long block_start;
    uInt match_length;            
    IPos prev_match;              
    int match_available;          
    uInt strstart;                
    uInt match_start;             
    uInt lookahead;               
    uInt prev_length;
    uInt max_chain_length;
    uInt max_lazy_match;
    int level;     
    int strategy;  
    uInt good_match;
    int nice_match;  
    struct ct_data_s dyn_ltree[(2*(256+1+29)+1)];    
    struct ct_data_s dyn_dtree[2*30+1];  
    struct ct_data_s bl_tree[2*19+1];   
    struct tree_desc_s l_desc;                
    struct tree_desc_s d_desc;                
    struct tree_desc_s bl_desc;               
    ush bl_count[15+1];
    int heap[2*(256+1+29)+1];       
    int heap_len;                
    int heap_max;                
    uch depth[2*(256+1+29)+1];
    uchf *l_buf;           
    uInt  lit_bufsize;
    uInt last_lit;       
    ushf *d_buf;
    ulg opt_len;         
    ulg static_len;      
    uInt matches;        
    uInt insert;         
    ush bi_buf;
    int bi_valid;
    ulg high_water;
}  deflate_state;

deflate.pp:

typedef struct internal_state {
    z_streamp strm;       
    int   status;         
    Bytef *pending_buf;   
    ulg   pending_buf_size;  
    Bytef *pending_out;   
    uInt   pending;       
    int   wrap;           
    gz_headerp  gzhead;   
    uInt   gzindex;       
    Byte  method;         
    int   last_flush;     
    uInt  w_size;         
    uInt  w_bits;         
    uInt  w_mask;         
    Bytef *window;
    ulg window_size;
    Posf *prev;
    Posf *head;  
    uInt  ins_h;           
    uInt  hash_size;       
    uInt  hash_bits;       
    uInt  hash_mask;       
    uInt  hash_shift;
    long block_start;
    uInt match_length;            
    IPos prev_match;              
    int match_available;          
    uInt strstart;                
    uInt match_start;             
    uInt lookahead;               
    uInt prev_length;
    uInt max_chain_length;
    uInt max_lazy_match;
    int level;     
    int strategy;  
    uInt good_match;
    int nice_match;  
    struct ct_data_s dyn_ltree[(2*(256+1+29)+1)];    
    struct ct_data_s dyn_dtree[2*30+1];  
    struct ct_data_s bl_tree[2*19+1];   
    struct tree_desc_s l_desc;                
    struct tree_desc_s d_desc;                
    struct tree_desc_s bl_desc;               
    ush bl_count[15+1];
    int heap[2*(256+1+29)+1];       
    int heap_len;                
    int heap_max;                
    uch depth[2*(256+1+29)+1];
    uchf *l_buf;           
    uInt  lit_bufsize;
    uInt last_lit;       
    ushf *d_buf;
    ulg opt_len;         
    ulg static_len;      
    uInt matches;        
    uInt insert;
    ush bi_buf;
    int bi_valid;
    ulg high_water;
}  deflate_state;

And then I also realized that _tr_tally() follows the same pattern then the other functions but it doesnt raise an exception as the others do.

Does anyone have any idea why I'm getting this error and how could I fix it? Or even, what further tests should I do? I also tried with TI 5.2.5 and TI 15.12.1 compilers. Same thing...

Thanks!

  • This is a link-time type checking error message. As a workaround, reduce the optimization level from -O4 to -O3 at link time.
    Usually this sort of problem occurs with nested structs, or pointers to incomplete types. You'll need to look at the definitions of struct ct_data_s and tree_desc_s, and any structs they might use, recursively. Try to make sure that struct types are defined in only one header file, and make sure all types are completely defined before declaring a pointer to that type.