We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2023-12-05 11:11 PM - last edited on 2024-09-17 12:44 PM by Doreena Deng
Here is something I have noticed this afternoon.
For the past couple of weeks I am getting my initiation into the world of CMake as I migrate our custom API work from 25 to 27. I continue to do this work with my only installation of VS2019.
Today I went back to make a few very basic edits to AC25 code that has been stable in the dev environment for years. I only changed a string value that holds a path to be a different path. Very basic.
Now, when I build this edit, I get a rash of errors with a source in the building blocks of the GS API. For example:
Build started...
1>------ Build started: Project: JHP_AutoLoad, Configuration: Release x64 ------
1>JHP_AutoLoad.cpp
1>G:\dev\v25\JHP_AutoLoad\Src\JHP_AutoLoad.cpp(107,47): error C2679: binary '=': no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(399,13): message : could be 'GS::UniString &GS::UniString::operator =(const GS::UniString::Concatenation &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(398,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::UniString::ConstSubstring &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(397,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::UniString::Substring &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(396,13): message : or 'GS::UniString &GS::UniString::operator =(GS::UniString &&)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(395,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::UniString &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(394,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::String &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(393,13): message : or 'GS::UniString &GS::UniString::operator =(const unsigned char *)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(392,13): message : or 'GS::UniString &GS::UniString::operator =(const char *)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(391,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::UniChar::Layout *)'
1>G:\dev\v25\JHP_AutoLoad\Src\JHP_AutoLoad.cpp(107,47): message : while trying to match the argument list '(GS::UniString, std::string)'
1>G:\dev\v25\JHP_AutoLoad\Src\JHP_AutoLoad.cpp(154,45): error C2679: binary '=': no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(399,13): message : could be 'GS::UniString &GS::UniString::operator =(const GS::UniString::Concatenation &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(398,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::UniString::ConstSubstring &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(397,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::UniString::Substring &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(396,13): message : or 'GS::UniString &GS::UniString::operator =(GS::UniString &&)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(395,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::UniString &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(394,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::String &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(393,13): message : or 'GS::UniString &GS::UniString::operator =(const unsigned char *)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(392,13): message : or 'GS::UniString &GS::UniString::operator =(const char *)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(391,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::UniChar::Layout *)'
1>G:\dev\v25\JHP_AutoLoad\Src\JHP_AutoLoad.cpp(154,45): message : while trying to match the argument list '(GS::UniString, std::string)'
1>G:\dev\v25\JHP_AutoLoad\Src\JHP_AutoLoad.cpp(171,49): error C2679: binary '=': no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(399,13): message : could be 'GS::UniString &GS::UniString::operator =(const GS::UniString::Concatenation &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(398,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::UniString::ConstSubstring &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(397,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::UniString::Substring &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(396,13): message : or 'GS::UniString &GS::UniString::operator =(GS::UniString &&)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(395,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::UniString &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(394,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::String &)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(393,13): message : or 'GS::UniString &GS::UniString::operator =(const unsigned char *)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(392,13): message : or 'GS::UniString &GS::UniString::operator =(const char *)'
1>C:\Program Files\GRAPHISOFT\API Development Kit 25.3002\Support\Modules\GSRoot\UniString.hpp(391,13): message : or 'GS::UniString &GS::UniString::operator =(const GS::UniChar::Layout *)'
1>G:\dev\v25\JHP_AutoLoad\Src\JHP_AutoLoad.cpp(171,49): message : while trying to match the argument list '(GS::UniString, std::string)'
1>Done building project "JHP_AutoLoad.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It is almost as if I somehow reconfigured my Visual Studio simply by working on the migration to 27 and CMake. I verified that my 'Additional Include Directories' for this 25 developmenet are still pointing to the API Dev Kit for 25.
In my mind, the .sln file for 25 is self-contained with the properties it needs for 25 as is the folder for 27 with the properties it needs for 27. And ..\GSRoot\UniString.hpp should not be giving me this push back just because I have worked with the AC27 API. Am I wrong in thinking that? I am not aware that anything else has changed. Am I alone in this?
And you may ask yourself, "♪♫♬My god, what have I done!♬♪♫"
Solved! Go to Solution.
2023-12-06 08:19 AM - edited 2023-12-06 08:22 AM
The API is constantly improving and sometimes it causes situations where something works with the new Development Kit, but doesn't work with an old one. The convenient interaction between GS::UniString and std::string was introduced in the DevKit for Archicad 27.
So this code will work with AC27, but not with AC25:
std::string myString = "hey";
GS::UniString myUniString;
myUniString = myString;
To resolve this situation, you can use a function that works with AC25, and it will work with AC27 as well:
std::string myString = "hey";
GS::UniString myUniString;
myUniString.Assign (myString.c_str (), CC_UTF8);
Another solution is to create a utility function that does the job depending on the version. It doesn't make a lot of sense in this case, but can be a good practice for other incompatibilities:
static GS::UniString GetUniString (const std::string& str)
{
#ifdef ServerMainVers_2700
return GS::UniString (str);
#else
return GS::UniString (str.c_str (), CC_UTF8);
#endif
}
// later in the code
std::string myString = "hey";
GS::UniString myUniString;
myUniString = GetUniString (myString);
2023-12-06 08:19 AM - edited 2023-12-06 08:22 AM
The API is constantly improving and sometimes it causes situations where something works with the new Development Kit, but doesn't work with an old one. The convenient interaction between GS::UniString and std::string was introduced in the DevKit for Archicad 27.
So this code will work with AC27, but not with AC25:
std::string myString = "hey";
GS::UniString myUniString;
myUniString = myString;
To resolve this situation, you can use a function that works with AC25, and it will work with AC27 as well:
std::string myString = "hey";
GS::UniString myUniString;
myUniString.Assign (myString.c_str (), CC_UTF8);
Another solution is to create a utility function that does the job depending on the version. It doesn't make a lot of sense in this case, but can be a good practice for other incompatibilities:
static GS::UniString GetUniString (const std::string& str)
{
#ifdef ServerMainVers_2700
return GS::UniString (str);
#else
return GS::UniString (str.c_str (), CC_UTF8);
#endif
}
// later in the code
std::string myString = "hey";
GS::UniString myUniString;
myUniString = GetUniString (myString);
2023-12-06 04:03 PM
Viktor,
Thanks for pinpointing the issue so quickly and precisely.
This will be easier to remedy now that I know which haystack to search for the needle.
Have a great day!
Chris