Choose your top Archicad wishes!

Read more
Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Switching dev from AC27 to AC25

MudratDetector
Enthusiast

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!♬♪♫"

Chris Gilmer
Intel i9-12950HX CPU @ 2.30GHz, 16 cores
NVIDIA GeForce RTX 3080
48.0 GB RAM
Windows 10 Pro 64-bit
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Viktor Kovacs
Graphisoft
Graphisoft

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);

 

 

View solution in original post

2 REPLIES 2
Solution
Viktor Kovacs
Graphisoft
Graphisoft

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);

 

 

MudratDetector
Enthusiast

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

Chris Gilmer
Intel i9-12950HX CPU @ 2.30GHz, 16 cores
NVIDIA GeForce RTX 3080
48.0 GB RAM
Windows 10 Pro 64-bit