Lots of error in C++ (190!)

Hello,
I am discovering C++ in UE4. Until now, I was programming in Blueprint but for some reasons I have to create a C++ class (a blueprint function library) to merge my meshes together.

I have programming notion in C and some in C++ but with Unreal Engine I am very lost.
First, I discovered that the official documentation to do what I would like have a lot of errors and thanks to some similar questions on the answerhub I find how to solve them.

So now, I finally resolved all my issues but there is something that I don’t understand. In the official documentation to merge mesh (here : Working with Modular Characters | Unreal Engine Documentation)

Here is a sample of the code :

USTRUCT(BlueprintType)
struct PROJECTNAME_API FSkelMeshMergeSectionMapping_BP
{
    GENERATED_BODY()
        /** Indices to final section entries of the merged skeletal mesh */
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mesh Merge Params")
        TArray<type> SectionIDs;
};

In this, they said that we should change the PROJECTNAME_API by the name of our project with _API at the end. I did it and it wasn’t working at all (almost 190 errors). I had syntax error, missing “;” or “)”… I also had problem with “FSkelMeshMergeSectionMapping_BP” that wasn’t defined and “Generated_body”.

I search a lot on the internet and finally I saw something where people where created struct without specify the “PROJECTNAME_API” so I deleted it and then everything work !

My question is : When do we need to specify the PROJECTNAME_API and when should we don’t ?

Thank you a lot !

All the best

The name should be uppercase if oyu don’t know same as example “PROJECTNAME”, it’s a macro so by C/C++ convention it should be uppercase.

Also you only need PROJECTNAME_API if you plan to use struct or class outside of your module (most common example is game project module accessing struct or class in plugin). The macro place “extern” statement when it needed (like non-monolithic build on editor and development build), extern makes struct or class elements accessible outside of dll, if oyu lack of it and try to access them externally you get linker errors during compilation.

So… yes, that macro is actually optional and only needed for case i mentioned above, so you can skip it if you want… or rather can.

Thank you a lot ! I better understand the problem :slight_smile: So in fact, if I have written “LEVELDESIGN_API” it would have worked.
Since it is not necessary in my case, it also worked without it.
Thank you for your answer, now I am able to understand it.