BIM Coordinator Program (INT) April 22, 2024
Find the next step in your career as a Graphisoft Certified BIM Coordinator!
Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

BNZeromemory Error in Archicad 27

mick-donald
Participant
Hello everyone.
I have this error when I use functions for ArchiCAD 26 to Archicad 27.
The functions are used for creating attributes, properties, walls, and slabs.
It is working well in Archicad 26 but there is such error in Archicad 27.
If anyone has an opinion or experience with this error, please help me.
----------------------------error----------------------------------------------
Static assertion failed due to requirement 'GS::IsVoid<API_ServerApplicationInfo> || GS::IsTriviallyCopyable<API_ServerApplicationInfo>': The parameter of BNZeroMemory should be trivially copyable.
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Viktor Kovacs
Graphisoft
Graphisoft

Earlier every Archicad struct was a POD type, so it was safe - and actually recommended - to call BNZeroMemory on them to initialize the object. Since the API is getting more and more modern, now there are some non-POD objects where it is not safe to zero the memory since it will corrupt the data structure.

 

The error you get means that you shouldn't call BNZeroMemory on the API_ServerApplicationInfo struct anymore. So you can safely skip the BNZeroMemory call since the constructor will do the initialization.

 

You may still want to call BNZeroMemory if you are targeting older Archicad versions, in this case this code will do the trick:

API_ServerApplicationInfo appInfo = {};
#ifndef ServerMainVers_2700
    BNZeroMemory (&appInfo, sizeof (appInfo));
#endif

 

 

View solution in original post

2 REPLIES 2
Solution
Viktor Kovacs
Graphisoft
Graphisoft

Earlier every Archicad struct was a POD type, so it was safe - and actually recommended - to call BNZeroMemory on them to initialize the object. Since the API is getting more and more modern, now there are some non-POD objects where it is not safe to zero the memory since it will corrupt the data structure.

 

The error you get means that you shouldn't call BNZeroMemory on the API_ServerApplicationInfo struct anymore. So you can safely skip the BNZeroMemory call since the constructor will do the initialization.

 

You may still want to call BNZeroMemory if you are targeting older Archicad versions, in this case this code will do the trick:

API_ServerApplicationInfo appInfo = {};
#ifndef ServerMainVers_2700
    BNZeroMemory (&appInfo, sizeof (appInfo));
#endif

 

 

Actually this code is redundant

#ifndef ServerMainVers_2700
    BNZeroMemory (&appInfo, sizeof (appInfo));
#endif

I've been using initializer list instead of BNZeroMemory or templated BNClear and it works fine since AC24 (I haven't tried with AC23 and older versions). Also, since C++ 11 the equal sign is optional, i.e.

API_ServerApplicationInfo appInfo{};

is enough.

Learn and get certified!