Skip to content
Snippets Groups Projects
Commit 0602373a authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Using functions to make sure initialization order is correct

parent 25cbe1c0
No related branches found
No related tags found
No related merge requests found
......@@ -29,17 +29,15 @@ namespace PLMD {
namespace config {
// This is a fix to allow conda to correctly replace paths in binary files.
// These variables should not be static or they will be optimized away!
// I guess the compiler thinks that they could be replaced from outside
// (even though they are const) and thus cannot optimize them.
const char* plumed_root="@PLUMED_ROOT@";
const char* plumed_soext="@SOEXT@";
const char* plumed_htmldir="@htmldir@";
const char* plumed_includedir="@includedir@";
const char* plumed_program_name="@program_name@";
// These functions should not be static or they will be optimized away!
const char* plumed_root(){return "@PLUMED_ROOT@";}
const char* plumed_soext(){return "@SOEXT@";}
const char* plumed_htmldir(){return "@htmldir@";}
const char* plumed_includedir(){return "@includedir@";}
const char* plumed_program_name(){return "@program_name@";}
std::string getSoExt() {
return plumed_soext;
return plumed_soext();
}
bool isInstalled() {
......@@ -50,7 +48,7 @@ std::string getPlumedRoot() {
char *env = std::getenv("PLUMED_ROOT");
std::string ss;
if( env == NULL) {
ss=plumed_root;
ss=plumed_root();
} else {
ss=std::string( env );
}
......@@ -62,7 +60,7 @@ std::string getPlumedHtmldir() {
char *env = std::getenv("PLUMED_HTMLDIR");
std::string ss;
if( env == NULL) {
ss=plumed_htmldir;
ss=plumed_htmldir();
} else {
ss=std::string( env );
}
......@@ -74,7 +72,7 @@ std::string getPlumedIncludedir() {
char *env = std::getenv("PLUMED_INCLUDEDIR");
std::string ss;
if( env == NULL) {
ss=plumed_includedir;
ss=plumed_includedir();
} else {
ss=std::string( env );
}
......@@ -86,7 +84,7 @@ std::string getPlumedProgramName() {
char *env = std::getenv("PLUMED_PROGRAM_NAME");
std::string ss;
if( env == NULL) {
ss=plumed_program_name;
ss=plumed_program_name();
} else {
ss=std::string( env );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment