Op 11-2-2011 2:00, Peter Kümmel schreef:
On 11.02.2011 00:34, Enrico Forestieri wrote:
On Fri, Feb 11, 2011 at 12:06:00AM +0100, Pavel Sanda wrote:
kuem...@lyx.org wrote:
Author: kuemmel
Date: Thu Feb 10 23:57:41 2011
New Revision: 37591
URL: http://www.lyx.org/trac/changeset/37591

Log:
compile.

Modified: lyx-devel/trunk/src/version.cpp
============================================================================== --- lyx-devel/trunk/src/version.cpp Thu Feb 10 23:44:59 2011 (r37590) +++ lyx-devel/trunk/src/version.cpp Thu Feb 10 23:57:41 2011 (r37591)
@@ -14,8 +14,8 @@
  ///
  char const * lyx_version = PACKAGE_VERSION;
  ///
-int lyx_version_major = LYX_MAJOR_VERSION;
-int lyx_version_minor = LYX_MINOR_VERSION;
+const int lyx_version_major = LYX_MAJOR_VERSION;
+const int lyx_version_minor = LYX_MINOR_VERSION;

it was no oversight i didn't put const there, since my linker chokes on it.
what was your error?
liblyxcore.a(Buffer.o): In function `lyx::Buffer::write(std::basic_ostream<char, std::char_traits<char> >&) const':
Buffer.cpp:(.text+0x16ee): undefined reference to `lyx_version_major'
Buffer.cpp:(.text+0x171c): undefined reference to `lyx_version_minor'
collect2: ld returned 1 exit status

maybe we need to kill const.

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.

Is there a reason not to use functions? ( int lyx_version_major(); )
Globals functions are evil. But global variables let hell look like a freezer.

Peter
As long as variables are declared const, it's not a real problem I guess. Technically, if they are const, they are no variables anymore.

At least one knows immediately that the global "variables" are constants, otherwise we would have used functions for sure. And one never knows whether a function always returns a constant or not. So, I feel like global functions are worse than const global variables, but better than non-const global variables.

Vincent



Reply via email to