We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

Cannot compile AC26 addon for AC27

YourQS
Booster

I have a plugin that compiles and works fine in AC26.   I am upgrading it to AC27.   I have installed the AC27 API kit and changed all references in the project file to the 27.3001 folder.

I now get about 6000 errors, many of them like these:

 

Code: 

 

 

CParameter* Factory(const API_AddParType &parameter);

 

 

 

Errors:

 

 

 

Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int
Error C2143 syntax error: missing ',' before '&'

 

 

 

The Visual Studio IDE is able to identify the type API_AddParType and can navigate to the .h file if I press F12 on the type, but the compiler doesn't seem to be able to find it. (See attached image)

 

Could someone help with what I need to change to resolve this issue?

 

AC27.PNG

 

25 REPLIES 25
Mihaly Palenik
Graphisoft
Graphisoft

Hello,

 

where do you put it exactly? Right before the first reference like this:

#ifndef _PARAMETERCOLLECTION_HPP_
#define _PARAMETERCOLLECTION_HPP_

#include "Definitions.hpp"

#include <vector>
#include "WString.hpp"
#include <Parameter.hpp>

using namespace std;

class CParameterCollection
{
protected:
vector<CParameter*> m_collection;

protected:
void ClearCollection();
void CopyCollection(const CParameterCollection &src);
// added line
struct API_AddParType;
CParameter* Factory(const API_AddParType &parameter);

or before the class like this?

#ifndef _PARAMETERCOLLECTION_HPP_
#define _PARAMETERCOLLECTION_HPP_

#include "Definitions.hpp"

#include <vector>
#include "WString.hpp"
#include <Parameter.hpp>

using namespace std;
// added line
struct API_AddParType;

class CParameterCollection
{
protected:
vector<CParameter*> m_collection;

protected:
void ClearCollection();
void CopyCollection(const CParameterCollection &src);

CParameter* Factory(const API_AddParType &parameter);

 

Akos Somorjai
Graphisoft
Graphisoft

Hi,

 

Another idea:

 

#include <vector>
#ifndef ACExtension
#define ACExtension
#endif
#include "APIdefs_LibraryParts.h"
#include "WString.hpp"

 

Best, Akos

Hi Mihaley,

 

I had put it before the class.   When I put it directly before the reference, it gets rid of one compiler error, but then throws this error:

 

Error C2027 use of undefined type 'CParameterCollection::API_AddParType'

 

Thanks and regards,

Nick

Hi Akos,

 

Yes, that seems to get rid of about 20 of the remaining 2000 compiler errors.

 

Thanks and regards,

Nick

Viktor Kovacs
Graphisoft
Graphisoft

Another idea: it seems that the DevKit also has a file named "Parameter.hpp" (Support/Modules/GSModelDevLib/Parameter.hpp). I can imagine that somehow the AC27 build finds the one in the DevKit before the one in your library. Please try to rename your file to e.g. "CParameter.hpp" and check if that solves the problem.

 

If this doesn't help, please provide the full build log. When you have so many errors sometimes the real reason is hidden somewhere in the log.

Hi Viktor,

 

I tried renaming Parameter.hpp, but it did not solve the problem.   I have attached a file with the build log.

 

Thanks and regards,

Nick

Viktor Kovacs
Graphisoft
Graphisoft

Most of the errors seemingly are coming from changes in the API interface between AC26 and AC27. There are - at least - two parts of the story.

 

1. API_AttributeIndex

API_AttributeIndex has been changed from a number to a class.

 

 

// AC26
typedef Int32 GSIndex;
typedef GSIndex API_AttributeIndex;

// AC27
class API_AttributeIndex
{
// ...
}

 

 

From the log it seems that you are using API_AttributeIndex as a number at several places, like in an std::map that requires a comparison operator that the new class doesn't have.

 

 

std::map<API_AttributeIndex, int> m;

 

 

Probably it will mean a bigger rewrite for you to use the class everywhere. For now you can get the index from the class, but I highly recommend using the class for future compatibility.

 

2. Function renames

Several functions has been renamed in AC27. For example ACAPI_LibPart_Get is called ACAPI_LibraryPart_Get in AC27.

 

What can you do?

You have two options:

  1. You can separate the code for AC26 and AC27 and do the update only in the AC27 codebase.
  2. If you prefer to have one code base for both versions you can create a header that resolves these dependencies.

Example for such migration header:

 

#ifndef ServerMainVers_2700

#define ACAPI_LibraryPart_GetNum ACAPI_LibPart_GetNum
#define ACAPI_LibraryPart_Search ACAPI_LibPart_Search
#define ACAPI_LibraryPart_Create ACAPI_LibPart_Create
// ...

#endif

 

 

Since there were many changes between the two versions, prepare for a bigger task to rewrite everything. In case of renames it's "only" a manual task, in case of attribute index handling you need to figure out what will work the best for you.

Hi Viktor,

 

Thanks for that.   Is there a list of function name changes?   I have looked at https://graphisoft.github.io/archicad-api-devkit/md__common_doxygen_files_2_articles_2_new_01_a_p_i_... but it just says that many names have changed.

 

Regards,

Nick

Hi Nick,

You can check the file Support/Inc/ACAPI_MigrationHeader.hpp in the AC27 SDK for a list of (I think) all function name changes.
Unfortunately I wasn't able to use the file directly without modifications.
I think I've used following modifications to use it:

  1. Make all functions inline
  2. Document out functions where the conversion doesn't work for some reason or fix it if I need exactly one of these.

Hope that helps!

Hi Bernd, Akos, and Viktor,

 

I have made the changes suggested by Akos for the renamed functions and new class.   I am still getting the original many errors where the compiler cannot find definitions , when the IDE can.

 

Bernd, I have taken your original suggestion of creating a small project that demonstrates the problem; the whole plugin is quite small, so I have attached it.   Please could you try opening and compiling it?

 

Thanks and regards,

Nick