I have the following definition of a global variable in a header that was included in several cpp file. I do have the #pragma once included.
// A.h // only declarations and variable definition here.
#pragma once
int i = 1;
class one{public: one(); int j, p=1;};
class two{public: two(); int m, q=10;};
// B.cpp // definition of class one methods
#include "A.h"
one::one(){j=i;}
// C.cpp // definition of class two methods
#include "A.h"
two::two(){m=i;}
// D.cpp
#include "A.h"
int main()
{
one b();
two a();
}
when compiling the compiler returns two error that both say int i has been defined in D.obj
.