On 02/11/2011 01:04 AM, Enrico Forestieri wrote:
On Fri, Feb 11, 2011 at 12:49:22AM +0100, Peter Kümmel wrote:
On 11.02.2011 00:34, Enrico Forestieri wrote:
No, const variables have internal linkage, so they will not be seen outside
their compile unit. Simply declare them as "extern" also in version.cpp.

You mean declaring it in the header as "extern const int i" is the same as
.h:   const int i;
.cpp  static int i;
No, I mean that if you want a global const variable with external linkage,
the correct C++ way of doing it is
.h    extern const int i;
.cpp  extern const int i =<value>;

This is misleading, a better fix is to let the cpp file to know about the header. So #include "version.h" is probably missing in version.cpp.

Abdel.


Reply via email to