Error 'duplicate definition' when compiling 2 c files that reference 1 header file
        Posted  
        
            by super newbie
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by super newbie
        
        
        
        Published on 2010-03-16T21:53:05Z
        Indexed on 
            2010/03/16
            22:01 UTC
        
        
        Read the original article
        Hit count: 375
        
I have two C files and one header that are as follows:
Header file header.h:
char c = 0;
file1.c:
#include "header.h"
file2.c:
#include "header.h"
I was warned about 'duplicate definition' when compiling. I understand the cause as the variable c is defined twice in both file1.c and file2.c; however, I do need to reference the header.h in both c files. How should I overcome this issue?
© Stack Overflow or respective owner