sheridp@umich.edu Posted March 15, 2019 Report Share Posted March 15, 2019 The following Dockerfile will reproduce the problem: FROM alpine:3.9 as builder RUN apk add --no-cache build-base linux-headers WORKDIR /opt FROM builder as builder_systemc COPY systemc-2.3.3.gz /opt RUN mkdir /opt/systemc_src && \ tar -xf systemc-2.3.3.gz -C /opt/systemc_src --strip-components=1 && \ cd /opt/systemc_src && ./configure --prefix /opt/systemc-2.3.3 --enable-debug CXXFLAGS="-DSC_CPLUSPLUS=201703L" && \ make -j$(nproc) && \ make install Which results in the following error: CXX kernel/sc_simcontext.lo In file included from kernel/sc_simcontext.cpp:57: ../../src/sysc/utils/sc_string_view.h:62:29: error: 'string_view' in namespace 'std' does not name a type typedef SC_STRING_VIEW_NS_::string_view sc_string_view; ^~~~~~~~~~~ It looks like the following is related: #if SC_CPLUSPLUS >= 201402L && defined(__has_include) # if SC_CPLUSPLUS > 201402L && __has_include(<string_view>) /* since C++17 */ # define SC_STRING_VIEW_NS_ std # include <string_view> /* available in Library Fundamentals, ISO/IEC TS 19568:2015 */ # elif __has_include(<experimental/string_view>) # define SC_STRING_VIEW_NS_ std::experimental # include <experimental/string_view> # endif #else // TODO: other ways to detect availability of std::(experimental::)string_view? #endif I'm guessing that defining SC_CPLUSPLUS did not cause the -std=c++17 flag to be passed to the compiler, because <string_view> contains the following: #if __cplusplus >= 201703L Update: Modifying the ./configure command to: ./configure --prefix /opt/systemc-2.3.3 --enable-debug CXXFLAGS="-DSC_CPLUSPLUS=201703L -std=c++17" solves the problem. It might be worthwhile mentioning this in the INSTALL notes. Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted March 16, 2019 Report Share Posted March 16, 2019 The INSTALL notes currently say the following about the SC_CPLUSPLUS preprocessor switch (emphasis mine): Quote This setting allows downgrading the assumed version of the underlying C++ standard on the current platform. By default, the latest supported version is chosen. Supported values are SC_CPLUSPLUS=199701L (C++03, ISO/IEC 14882:1998, 14882:2003) SC_CPLUSPLUS=201103L (C++11, ISO/IEC 14882:2011) SC_CPLUSPLUS=201402L (C++14, ISO/IEC 14882:2014) SC_CPLUSPLUS=201703L (C++17, ISO/IEC 14882:2017) This means, that you can explicitly opt-out of some SystemC features, that would generally be supported by your compiler's C++ language support. Selecting a newer C++ standard version than supported by your compiler (setup) will typically not work - as you have experienced. That said, adding a preprocessor flag on the compiler command-line does not affect the language mode of the compiler. How to switch your compiler to C++17 mode is outside of the scope of SystemC. Your compiler (version) seems to require the -std=c++17 switch to enable this mode. The SC_CPLUSPLUS flag is then not needed as it will be set automatically to the selected version. Hope that helps, Philipp Quote Link to comment Share on other sites More sharing options...
sheridp@umich.edu Posted March 21, 2019 Author Report Share Posted March 21, 2019 Hi Philipp, Thanks for your response. You are right, I think the spec is clear on that point. I think I had some confusion regarding the default flags on the compiler, but, as you pointed out, that is beyond the scope of the SystemC spec. Quote Link to comment Share on other sites More sharing options...
Grisha Posted April 15, 2019 Report Share Posted April 15, 2019 On 3/15/2019 at 11:12 PM, sheridp@umich.edu said: It might be worthwhile mentioning this in the INSTALL notes. +1. I tried to understand why I can't build under c++14 very long. Until I found this post. Thank you. Quote Link to comment Share on other sites More sharing options...
Soumyajeet Posted August 6, 2021 Report Share Posted August 6, 2021 On 3/16/2019 at 3:33 PM, Philipp A Hartmann said: The INSTALL notes currently say the following about the SC_CPLUSPLUS preprocessor switch (emphasis mine): This means, that you can explicitly opt-out of some SystemC features, that would generally be supported by your compiler's C++ language support. Selecting a newer C++ standard version than supported by your compiler (setup) will typically not work - as you have experienced. That said, adding a preprocessor flag on the compiler command-line does not affect the language mode of the compiler. How to switch your compiler to C++17 mode is outside of the scope of SystemC. Your compiler (version) seems to require the -std=c++17 switch to enable this mode. The SC_CPLUSPLUS flag is then not needed as it will be set automatically to the selected version. Hope that helps, Philipp Hello Philipp, May I know what is the state of C++20 support for SystemC? When I tried to build a project with C++20 I got a linker error. I tried to find a suitable preprocessor switch for C++20 in the INSTALL notes but there isn't any. Kindly let me know. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.