R
Rolf S. Arvidson
Be kind, a newb question here. I don't understand why I get a compile-time
error from the following:
I define a variable in main.cpp as such
double x = 1.;
int _tmain(int argc, _TCHAR* argv[]){
...;
}
In separate files that main calls, I have access to this global variable x,
extern double x;
void file2(){
x = szVi - 2.
}
No problem. However, I want to make this to be a constant, not a variable,
to ensure it's never alered by mistake.
But if I change the definition in main to extern,
const double x = 1.;
int _tmain(int argc, _TCHAR* argv[]){
...;
}
the linker can't resolve it:
error LNK2001: unresolved external symbol "double szVi" (?x@@3NA)
What am I doing wrong? How do I make this const visible to all files that
need it?
error from the following:
I define a variable in main.cpp as such
double x = 1.;
int _tmain(int argc, _TCHAR* argv[]){
...;
}
In separate files that main calls, I have access to this global variable x,
extern double x;
void file2(){
x = szVi - 2.
}
No problem. However, I want to make this to be a constant, not a variable,
to ensure it's never alered by mistake.
But if I change the definition in main to extern,
const double x = 1.;
int _tmain(int argc, _TCHAR* argv[]){
...;
}
the linker can't resolve it:
error LNK2001: unresolved external symbol "double szVi" (?x@@3NA)
What am I doing wrong? How do I make this const visible to all files that
need it?