Struct initialization error: multiple definition on TuBL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Abel Esgueva

    #1

    Struct initialization error: multiple definition on TuBL

    Can anyone tell me why this piece of program:


    Code:
    typedef struct
    {
    	int s0;
    	int s1;
    }MyBL;
    
    
    MyBL TuBL = {22, 23};
    gives a compiler/linker error "multiple definition on TuBL"
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    Does this snippet of code occur in a header file? If so, then TuBL is defined each time the header file is included.

    Is it possible that some other global symbol called TuBL exists somewhere else in your code? The other instance of TuBL might be a different type and be for a completely different purpose. It might even be a function name.

    You could sidestep global namespace conflicts if TuBL were defined static; that is, as a local variable.

    Comment

    Working...