C++ Create A Simple Struct!

Hi!

I’m an experienced C++ developer, and I don’t want to deal with blueprints. But what I cannot realize is that: “HOW DO I CREATE A SIMPLE STRUCT?”.

Do I create it from Visual Studio? Simply create a header file and type my struct?
Do I create it from the editor? There is no option to create a USTRUCT.

What is wrong with this?



#pragma once

#include "Engine/StaticMesh.h"

USTRUCT()
struct MYPROJECT_API FMyStruct
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	UStaticMesh *Mesh1;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	UStaticMesh *Mesh2;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	UStaticMesh *Mesh3;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	float AFloat;

	public FMyStruct()
		: AFloat(0.0f)
	{

	}
};


The compiler it resulting in a bunch of errors. It think does not recognize USTRUCT() or GENERATED_USTRUCT_BODY().

Thanks!

2 Likes

Would be nice if you could post the exact errors it is giving you.
struct MYPROJECT_API FMyStruct
what about removing the “MYPROJECT_API” here. I think it is not needed/ valid to have this at this location.

Here is the errors:

15	IntelliSense: variable "EObjectFlags" is not a type name	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	43	137	MyProject
22	IntelliSense: variable "EObjectFlags" is not a type name	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	62	128	MyProject
90	IntelliSense: variable "EObjectFlags" is not a type name	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	151	141	MyProject
24	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	12	17	MyProject
27	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	14	1	MyProject
30	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	15	1	MyProject
33	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	16	1	MyProject
36	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	17	1	MyProject
39	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	18	1	MyProject
42	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	19	1	MyProject
45	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	20	1	MyProject
48	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	21	1	MyProject
51	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	22	1	MyProject
54	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	23	1	MyProject
57	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	24	1	MyProject
60	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	26	1	MyProject
63	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	27	1	MyProject
66	IntelliSense: this declaration has no storage class or type specifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	33	1	MyProject
12	IntelliSense: TArray is not a template	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	43	74	MyProject
19	IntelliSense: TArray is not a template	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	62	64	MyProject
23	IntelliSense: TArray is not a template	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	71	64	MyProject
70	IntelliSense: TArray is not a template	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	53	8	MyProject
73	IntelliSense: TArray is not a template	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	57	8	MyProject
78	IntelliSense: TArray is not a template	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	132	17	MyProject
69	IntelliSense: name followed by '::' must be a class or namespace name	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	40	15	MyProject
83	IntelliSense: incomplete type is not allowed	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	137	22	MyProject
103	IntelliSense: identifier "UPackageMap" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	184	156	MyProject
79	IntelliSense: identifier "UPackage" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	134	17	MyProject
4	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	22	1	MyProject
8	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	34	1	MyProject
13	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	43	81	MyProject
20	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	62	71	MyProject
71	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	53	15	MyProject
74	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	57	15	MyProject
80	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	136	35	MyProject
84	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	137	37	MyProject
87	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	151	17	MyProject
88	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	151	63	MyProject
91	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	152	17	MyProject
92	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	152	59	MyProject
93	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	153	17	MyProject
94	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	153	66	MyProject
95	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	154	17	MyProject
96	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	154	63	MyProject
97	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	168	91	MyProject
98	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	168	110	MyProject
100	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	184	17	MyProject
101	IntelliSense: identifier "UObject" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	184	59	MyProject
5	IntelliSense: identifier "UClass" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	22	40	MyProject
9	IntelliSense: identifier "UClass" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	34	40	MyProject
76	IntelliSense: identifier "TInlineAllocator" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	57	24	MyProject
28	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	14	27	MyProject
31	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	15	27	MyProject
34	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	16	27	MyProject
37	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	17	27	MyProject
40	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	18	27	MyProject
43	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	19	27	MyProject
46	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	20	39	MyProject
49	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	21	39	MyProject
52	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	22	39	MyProject
55	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	23	28	MyProject
58	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	24	27	MyProject
61	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	26	35	MyProject
64	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	27	35	MyProject
67	IntelliSense: identifier "TEXT" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	33	27	MyProject
81	IntelliSense: identifier "Outer" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	136	45	MyProject
85	IntelliSense: identifier "Outer" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	137	46	MyProject
10	IntelliSense: identifier "ObjectClass" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	34	48	MyProject
16	IntelliSense: identifier "NULL" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	52	113	MyProject
99	IntelliSense: identifier "NULL" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	168	150	MyProject
102	IntelliSense: identifier "NULL" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	184	120	MyProject
18	IntelliSense: identifier "NAME_None" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	52	141	MyProject
25	IntelliSense: identifier "LogUObjectGlobals" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	12	45	MyProject
17	IntelliSense: identifier "FName" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	52	119	MyProject
89	IntelliSense: identifier "FName" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	151	81	MyProject
6	IntelliSense: identifier "Class" is undefined	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	22	48	MyProject
77	IntelliSense: expected an identifier	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	57	45	MyProject
14	IntelliSense: expected an expression	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	43	90	MyProject
21	IntelliSense: expected an expression	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	62	80	MyProject
72	IntelliSense: expected an expression	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	53	23	MyProject
75	IntelliSense: expected an expression	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	57	23	MyProject
7	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	22	53	MyProject
11	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectHash.h	34	59	MyProject
26	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	12	62	MyProject
29	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	14	50	MyProject
32	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	15	49	MyProject
35	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	16	68	MyProject
38	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	17	45	MyProject
41	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	18	45	MyProject
44	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	19	49	MyProject
47	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	20	64	MyProject
50	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	21	69	MyProject
53	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	22	69	MyProject
56	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	23	57	MyProject
59	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	24	43	MyProject
62	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	26	53	MyProject
65	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	27	57	MyProject
68	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	33	57	MyProject
82	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	136	50	MyProject
86	IntelliSense: expected a ')'	c:\Program Files\Epic Games\4.7\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h	137	51	MyProject

Error 3 error MSB3073: The command ““C:\Program Files\Epic Games\4.7\Engine\Build\BatchFiles\Build.bat” MyProjectEditor Win64 Development “D:\Users\TolgaAkyay\Source\MyProject\MyProject.uproject” -rocket” exited with code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets 38 5 MyProject
Error 2 error code: OtherCompilationError (2) D:\Users\TolgaAkyay\Source\MyProject\Intermediate\ProjectFiles\Error MyProject
Error 1 error : In TemporaryUHTHeader_MyStruct: Missing ‘:’ in after public D:\Users\TolgaAkyay\Source\MyProject\Source\MyProject\MyStruct.h 22 1 MyProject

Note my edit on the reply above. Maybe this could be a reason for it failing.

I think you are missing some header files. Go in editor and add code to project and create a class. See how it is declared and what headers are included and adapt it to your struct file.

Ok corrected like that:



#pragma once

#include "Engine/StaticMesh.h"

USTRUCT()
struct MYPROJECT_API FMyStruct
{
	GENERATED_USTRUCT_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	UStaticMesh *Mesh1;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	UStaticMesh *Mesh2;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	UStaticMesh *Mesh3;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	float AFloat;

        FMyStruct()
		: AFloat(0.0f)
	{

	}
};


Should be like that. At some point my mind jumped to C# :). But I’m still receiving compile errors. If I create a class from the editor, it generates a .generated.h file. But since I create it from VS environment, there is no .generated.h file. Also in editor I cannot create a USTRUCT.

Read here about structs in ue4:

https://wiki.unrealengine.com/Structs,_USTRUCTS%28%29,_They%27re_Awesome#Overview

I read this already!

Recreated and this worked for me (It compiled and opened the editor):


#pragma once

#include "Engine.h"

USTRUCT()
struct SNOW_API FStruct
{
	GENERATED_USTRUCT_BODY()

		UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Test")
		int32 n32test;

	FStruct()
	{

	}
};

Ok this comes to my first question: Did you create this struct by adding a header file in VS environment? Thanks for your efforts :slight_smile:

Yes I created a new header file in VS :). Do you have your “Engine.h” included?

Yes I tried that.

Also I’m not sure if you should use structs in a separate header file when working with ue4. I always had my structs in my .h file of a class before the class declaration when working with ue4.

I quote from the wiki article:

Ok finally I compiled it :slight_smile: Thank you very much for your time!

One thing is the compiler expects to include MyStruct.generated.h as the last include line. Others are my mistakes.

1 Like

Hi Bumbala,

How did you create MyStruct.generated.h?

Thanks!

It will be automatically created by build system for every file that has UCLASS or USTRUCT in it.

Thanks, NegInfinity! I just created the .h from Visual Studio and it goes into \Intermediate so nothing happened. I wanted to delete my post : )

Since it doesn’t seem like it was ever mentioned and most of the confusion here seems to of been caused from a lack of what the actual error was, when you see the line “OtherCompilationError (2)” in your error list, always check the Output log as it will provide more insight into what the actual error is. This is due to that particular error not having a error message tied to it so the error list gives a generic message.

Also please note that you do not need, and should not use the MY_API with structs. That is for exporting class functions. If you need such functions you should be using a class, not a struct.
As long as all the code is in the header file, there is no need for a typedef to define whether or not it´s exported, since all the code is right there in the header file.

Given your statement that you are an experienced C++ developer, that is something you should be aware of already.

^ i resent that given UE4’s clear lack of docs on anything but blueprints, especially when intellesense wont let you compile based on its own parsing