[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kcm-grub2] /: Oops. Multiple definitions in different translation units.
From:       Konstantinos Smanis <konstantinos.smanis () gmail ! com>
Date:       2013-10-27 17:35:39
Message-ID: E1VaUFX-0000rD-10 () scm ! kde ! org
[Download RAW message or body]

Git commit b109284c30244f779e7be50dc33412301063dd58 by Konstantinos Smanis.
Committed on 27/10/2013 at 17:24.
Pushed by ksmanis into branch 'master'.

Oops. Multiple definitions in different translation units.

Inline the functions in order to share the definition in all translation
units.

Making these functions static is *wrong*! Each translation unit would
have a different copy of the function and thus different static local
variables. This kills the purpose of caching the value in a single
static local variable. Construct-On-First-Use would still work but with
different copies of the variable.

An excellent summary of the avaiable options can be found here:
http://stackoverflow.com/a/10847368/1266511

M  +9    -9    config.h.cmake

http://commits.kde.org/kcm-grub2/b109284c30244f779e7be50dc33412301063dd58

diff --git a/config.h.cmake b/config.h.cmake
index 24d2b68..25475af 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -12,47 +12,47 @@
 //Qt
 #include <QFile>
 
-const QString & grubInstallExePath()
+inline const QString & grubInstallExePath()
 {
     static const QString str = QFile::decodeName("@GRUB_INSTALL_EXE@");
     return str;
 }
-const QString & grubMkconfigExePath()
+inline const QString & grubMkconfigExePath()
 {
     static const QString str = QFile::decodeName("@GRUB_MKCONFIG_EXE@");
     return str;
 }
-const QString & grubProbeExePath()
+inline const QString & grubProbeExePath()
 {
     static const QString str = QFile::decodeName("@GRUB_PROBE_EXE@");
     return str;
 }
-const QString & grubSetDefaultExePath()
+inline const QString & grubSetDefaultExePath()
 {
     static const QString str = QFile::decodeName("@GRUB_SET_DEFAULT_EXE@");
     return str;
 }
-const QString & grubMenuPath()
+inline const QString & grubMenuPath()
 {
     static const QString str = QFile::decodeName("@GRUB_MENU@");
     return str;
 }
-const QString & grubConfigPath()
+inline const QString & grubConfigPath()
 {
     static const QString str = QFile::decodeName("@GRUB_CONFIG@");
     return str;
 }
-const QString & grubEnvPath()
+inline const QString & grubEnvPath()
 {
     static const QString str = QFile::decodeName("@GRUB_ENV@");
     return str;
 }
-const QString & grubMemtestPath()
+inline const QString & grubMemtestPath()
 {
     static const QString str = QFile::decodeName("@GRUB_MEMTEST@");
     return str;
 }
-const QString & grubLocalePath()
+inline const QString & grubLocalePath()
 {
     static const QString str = QFile::decodeName("@GRUB_LOCALE@");
     return str;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic