I have some C++ code, which requires the ISO C++ 2011 standard and also uses SystemC functionality. Therefore I guess it makes most sense to build the SystemC library with the same standard. For the build MinGW should be used. I already did the complete setup once with Visual Studio successfully and have to switch to MinGW now.
My problem is now, that when I try to build the SystemC library with anything else than CMAKE_CXX_STANDARD 98 (I tried 11, 14 and 17), I get the following outcome:
C:\SystemC_MinGW\systemc-2.3.4_pub_rev_20190614\build>mingw32-make.exe
Scanning dependencies of target systemc
[ 0%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_clock.cpp.obj
[ 0%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_event_finder.cpp.obj
[ 3%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_event_queue.cpp.obj
[ 3%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_export.cpp.obj
[ 3%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_interface.cpp.obj
[ 6%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_mutex.cpp.obj
[ 6%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_port.cpp.obj
[ 6%] Building CXX object src/CMakeFiles/systemc.dir/sysc/communication/sc_prim_channel.cpp.obj
In file included from C:\SystemC_MinGW\systemc-2.3.4_pub_rev_20190614\src\sysc\communication\sc_prim_channel.cpp:37:
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:63:18: error: 'mutex' in namespace 'std' does not name a type
typedef std::mutex underlying_type;
^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:63:13: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:37:1:
+#include <mutex>
#elif !defined(WIN32) && !defined(_WIN32) // use pthread mutex
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:63:13:
typedef std::mutex underlying_type;
^~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:131:5: error: 'underlying_type' does not name a type; did you mean '__underlying_type'?
underlying_type m_mtx;
^~~~~~~~~~~~~~~
__underlying_type
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h: In member function 'void sc_core::sc_host_mutex::do_lock()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:66:25: error: 'm_mtx' was not declared in this scope
void do_lock() { m_mtx.lock(); }
^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h: In member function 'bool sc_core::sc_host_mutex::do_trylock()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:67:32: error: 'm_mtx' was not declared in this scope
bool do_trylock() { return m_mtx.try_lock(); }
^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h: In member function 'void sc_core::sc_host_mutex::do_unlock()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:68:25: error: 'm_mtx' was not declared in this scope
void do_unlock() { m_mtx.unlock(); }
^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h: In constructor 'sc_core::sc_host_mutex::sc_host_mutex()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_mutex.h:109:23: error: class 'sc_core::sc_host_mutex' does not have any field named 'm_mtx'
sc_host_mutex() : m_mtx()
^~~~~
In file included from C:\SystemC_MinGW\systemc-2.3.4_pub_rev_20190614\src\sysc\communication\sc_prim_channel.cpp:38:
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h: At global scope:
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:61:12: error: 'mutex' in namespace 'std' does not name a type
std::mutex mtx;
^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:61:7: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:38:1:
+#include <mutex>
#elif !defined(WIN32) && !defined(_WIN32) // use POSIX semaphore
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:61:7:
std::mutex mtx;
^~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:62:12: error: 'condition_variable' in namespace 'std' does not name a type
std::condition_variable cond_var;
^~~~~~~~~~~~~~~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:62:7: note: 'std::condition_variable' is defined in header '<condition_variable>'; did you forget to '#include <condition_variable>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:38:1:
+#include <condition_variable>
#elif !defined(WIN32) && !defined(_WIN32) // use POSIX semaphore
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:62:7:
std::condition_variable cond_var;
^~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h: In member function 'void sc_core::sc_host_semaphore::do_wait()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:69:29: error: 'mutex' is not a member of 'std'
std::unique_lock<std::mutex> lock(m_sem.mtx);
^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:69:29: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:69:29: error: 'mutex' is not a member of 'std'
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:69:29: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:69:34: error: template argument 1 is invalid
std::unique_lock<std::mutex> lock(m_sem.mtx);
^
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:69:47: error: 'struct sc_core::sc_host_semaphore::underlying_type' has no member named 'mtx'
std::unique_lock<std::mutex> lock(m_sem.mtx);
^~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:71:15: error: 'struct sc_core::sc_host_semaphore::underlying_type' has no member named 'cond_var'
m_sem.cond_var.wait(lock);
^~~~~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h: In member function 'bool sc_core::sc_host_semaphore::do_trywait()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:77:29: error: 'mutex' is not a member of 'std'
std::unique_lock<std::mutex> lock(m_sem.mtx);
^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:77:29: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:77:29: error: 'mutex' is not a member of 'std'
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:77:29: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:77:34: error: template argument 1 is invalid
std::unique_lock<std::mutex> lock(m_sem.mtx);
^
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:77:47: error: 'struct sc_core::sc_host_semaphore::underlying_type' has no member named 'mtx'
std::unique_lock<std::mutex> lock(m_sem.mtx);
^~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h: In member function 'void sc_core::sc_host_semaphore::do_post()':
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:85:29: error: 'mutex' is not a member of 'std'
std::unique_lock<std::mutex> lock(m_sem.mtx);
^~~~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:85:29: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:85:29: error: 'mutex' is not a member of 'std'
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:85:29: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:85:34: error: template argument 1 is invalid
std::unique_lock<std::mutex> lock(m_sem.mtx);
^
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:85:47: error: 'struct sc_core::sc_host_semaphore::underlying_type' has no member named 'mtx'
std::unique_lock<std::mutex> lock(m_sem.mtx);
^~~
C:/SystemC_MinGW/systemc-2.3.4_pub_rev_20190614/src/sysc/communication/sc_host_semaphore.h:87:13: error: 'struct sc_core::sc_host_semaphore::underlying_type' has no member named 'cond_var'
m_sem.cond_var.notify_one();
^~~~~~~~
mingw32-make.exe[2]: *** [src\CMakeFiles\systemc.dir\build.make:180: src/CMakeFiles/systemc.dir/sysc/communication/sc_prim_channel.cpp.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:858: src/CMakeFiles/systemc.dir/all] Error 2
mingw32-make.exe: *** [Makefile:148: all] Error 2
My complete workflow is as follows:
Did anybody encounter the same issue and has a solution or does anybody has a hint what I could have done wrong?
The build is possible by using these two additional CMAKE flags: CMAKE_C_FLAGS:STRING=-DSC_CPLUSPLUS=199701L and CMAKE_CXX_FLAGS:STRING=-DSC_CPLUSPLUS=199701L. They make it possible to build with a newer standard (e.g. 2011 or 2014) while not using the new features, which apparently don't work well.