Error compiling string constexpr

2 posts / 0 new
Last post
Offline
Last seen: 3 months 3 weeks ago
Joined: 02/07/2020
Posts: 21
Error compiling string constexpr

rtiddsgen 3.1.2 targeting C++11 generates a const string as follows:

static const std::string topic_name = "TopicName";
rtiddsgen 4.2.0 generates:
RTI_CONSTEXPR_OR_CONST_STRING std::string topic_name = "TopicName";
where RTI_CONSTEXPR_OR_CONST_STRING is a define to be "constexpr".
 
When compiling with clang 17, it generates the following error:
constexpr variable cannot have non-literal type 'const std::string' (aka 'const basic_string<char>')
And, sure enough, you cannot use std::string for a constexpr prior to at least C++20 (and, even then, it's not clear to me that it's supported).  Unless there's something I'm overlooking, the generated code should be reverted back to the prior version (static const).
Keywords:
Howard's picture
Offline
Last seen: 2 days 15 hours ago
Joined: 11/29/2012
Posts: 573

Hi, you're running into a known issue with rtiddsgen for Connext 7.2.0 and C++17.  It's being fixed for a future release.  I think that your account team is getting in touch to help resolve this issue for you.