Compiles on gcc 3.3 but not on gcc 4.0.3
This regards a source I downloaded. On one computer, an OS X, I have gcc 3.3 installed. On another, a Linux, I have gcc 4.0.3. The website I got it from stated that it would compile on both Linux and OS X, but it only compiles on OS X. With regard to a previous post,
I'm guessing this is more an issue of gcc version rather than platform.
Well, I've run into more trouble, and this time, it has to do with the declaration of an external variable.
Here's the relevant declaration in "Globals.h"
Unfortunately, this PROB_SMOOTH variable is being used in tons of other places, for example, the header "NTables.h" makes use of this.
extern float PROB_SMOOTH;
A sample bit of code is:
As I've commented in the last line, gcc 4.0.3 on Linux throws an error about "PROB_SMOOTH" was not declared in this scope. And it's true. I've traced back all the headers that are included in "NTables.h" and none of them are "Globals.h".
template <class VALTYPE>
Array2<VALTYPE, Vector<VALTYPE> > ntab;
nmodel(int maxw, int maxn)
: ntab(maxw, maxn, 0.0)
VALTYPE getValue(int w, unsigned int n)const
return max(ntab(w, n), VALTYPE(PROB_SMOOTH)); \\throws error here
The strange thing about it is, if I use gcc 3.3 on Mac OS 10.3, the entire thing compiles.
And the external declaration doesn't make sense to me either. By my understanding, you declare "extern" in the file where it's going to be used. Here, it's declared once in "Globals.h" where there are no function definitions whatsoever.
One way I could fix it, I guess is by including "Globals.h" in the file or declaring PROB_SMOOTH in every file that uses it as "extern". But I have a nagging feeling that that is incorrect.
Sorry I've been so long-winded. Any help would be dearly appreciated.
And for the curious, here's a link to the entire source: