简体   繁体   中英

Compiler error for std::string in c++ builder XE3 project

I am working on a service application in c++ builder XE3. I am getting compiler error for std::string if I add this line:

string a = string("abcd") + "xyz";

Error output is as follows:

[bcc32 Error] string(141): E2285 Could not find a match for 'move<_Ty>(string)'
  Full parser context
string(140): decision to instantiate: string std::string + <char,char_traits<char>,allocator<char> >(string &&,const char *)
--- Resetting parser context for instantiation...
svcmain.cpp(21): #include C:\Program Files\Embarcadero\RAD Studio\10.0\include\boost_1_39\boost\tr1\tr1\string
string(20): #include c:\program files\embarcadero\rad studio\10.0\include\../include/dinkumware/string
string(7): namespace std
string(140): parsing: string std::string + <char,char_traits<char>,allocator<char> >(string &&,const char *)

I tried to add #include <utility> just above #include <string> but still getting same error. Instead, if I split the line into two as follows, it compiles without errors.

string a = string("abcd");
a += "xyz";

OR

string b = string("abcd");
string a = b + "xyz";

Its not practical to use this workaround as I have to use existing code which is getting large no of errors. Same code works without errors in other XE3 project. Any ideas how to fix this error?

I found the fix in the other project. Setting the "backward compatibility" option to false fixed the error. You can find the checkbox in - Project options -> C++ compiler -> Compatibility -> General. This was initially set to true.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM