Anonymous
-
2021-08-13
Post awaiting moderation.
When GetPot (2.0) C++ header is included in multiple source files, the program cannot be linked with errors like:
/usr/bin/ld: particles.o: in function `GetPot::__constraint_check_PRIMARY(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const**) const':
/home/rouckas/include/GetPot.cpp:2308: multiple definition of `GetPot::__constraint_check_PRIMARY(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const**) const'; /tmp/cciWvHmf.o:/home/rouckas/include/GetPot.cpp:2308: first defined here
A simple solution is to prepend __GETPOT_INLINE to all check functions in GetPot.cpp as
$ diff -u0 getpot-c++-2.0/getpot-c++/GetPot.cpp GetPot.cpp
--- getpot-c++-2.0/getpot-c++/GetPot.cpp 2017-12-30 11:50:00.000000000 +0100
+++ GetPot.cpp 2021-08-11 15:51:45.663550220 +0200
@@ -2212,0 +2213 @@
+__GETPOT_INLINE
@@ -2251,0 +2253 @@
+__GETPOT_INLINE
@@ -2266,0 +2269 @@
+__GETPOT_INLINE
@@ -2288,0 +2292 @@
+__GETPOT_INLINE
@@ -2303,0 +2308 @@
+__GETPOT_INLINE
Anonymous