zamy
(zamy)
February 21, 2015, 1:46pm
1
Hello guys, i’m working on Windows, with branch 4.6.
Here’s some code:
USTRUCT()
struct FDataUnion
{
GENERATED_USTRUCT_BODY()
TUnion<FVector, UObject*> Union;
};
USTRUCT()
struct FCommandInfo
{
GENERATED_USTRUCT_BODY()
TArray<uint32> UnitIds;
FDataUnion Data; //simple union
};
In a UObject derived class, this compiles without problem, but if i try to make an array:
USTRUCT()
struct FDataUnion
{
GENERATED_USTRUCT_BODY()
TUnion<FVector, UObject*> Union;
};
USTRUCT()
struct FCommandInfo
{
GENERATED_USTRUCT_BODY()
TArray<uint32> UnitIds;
TArray<FDataUnion> Data; //array of unions
};
i get this strange compiling error:
[17/17] Link UE4Editor-Impero.dll
1> Creating of library ****\Intermediate\Build\Win64\ImperoEditor\Development\UE4Editor-Impero.lib and the object ****\Intermediate\Build\Win64\ImperoEditor\Development\UE4Editor-Impero.exp ...
1>Impero.generated.cpp.obj : error LNK2001: unresolved external symbol "struct FLogCategoryLogUnion LogUnion" (?LogUnion@@3UFLogCategoryLogUnion@@A)
1>****\Binaries\Win64\UE4Editor-Impero.dll : fatal error LNK1120: 1 external not solved
(note, i slightly modified and translated the output)
It’s the first time i find thiss error, and there’s no info about it.
Even removing the USTRUCT macros from FDataUnion doesn’t help.
zamy
(zamy)
February 21, 2015, 1:50pm
2
A TArray (of the first version, with simple union) works instead.
zamy
(zamy)
February 21, 2015, 1:58pm
3
Not any particular reason, i’m just testing some stuffs. I’ll try to add UPROPERTYs
zamy
(zamy)
February 21, 2015, 2:02pm
4
I’ll send it on a server replicated function, so i don’t want the transient flag
Anyway, i can’t set the UPROPERTY on FDataUnion::Union, it states
Unrecognized type ‘TUnion’
Moss
(Moss)
February 21, 2015, 1:54pm
5
The error suggest that your are using a log incorrectly but nothing related to your structs. Is there any reason why you are not using UPROPERTYs?
Moss
(Moss)
February 21, 2015, 1:59pm
6
If you do not want to serialize the content of the properties, if they are only populated and used in runtime, you can use the transient property flag.
Moss
(Moss)
February 21, 2015, 2:15pm
8
Do you use ‘LogUnion’ somewhere? It seams to be a UE_LOG category.
zamy
(zamy)
February 21, 2015, 2:02pm
9
i forgot: it requires ofc his include:
#include "Union.h"
zamy
(zamy)
February 21, 2015, 2:13pm
10
No moss, i already had the include, i forgot to mention it if someone wants to try the code
The situation didn’t change
zamy
(zamy)
February 21, 2015, 2:20pm
11
Nope. Just created this 2 structs. I just have it in my class to test if it compiles with a
TArray<FCommandInfo> t;
But i added it later, the problem is present just declaring those structs as they are written in here
Moss
(Moss)
February 23, 2015, 3:31pm
12
I’ll make a test this afternoon and post my results ^^
zamy
(zamy)
February 23, 2015, 3:12pm
13
ok, now this is strange:
using this struct
USTRUCT()
struct FDataUnion
{
GENERATED_USTRUCT_BODY()
TUnion<FVector, UObject*> Union;
};
in another struct with an array, like this:
USTRUCT()
struct FCommandInfo
{
GENERATED_USTRUCT_BODY()
UPROPERTY()
TArray<FTempStruct> Data;
};
will generate the compile error just with the declaration, but if we use it directly in a class like this:
UCLASS()
class UCommand : public UObject
{
GENERATED_BODY()
public:
TArray<FDataUnion> t;
};
will work.
zamy
(zamy)
February 23, 2015, 3:12pm
14
I’m going to look closely at the TUnion declaration.
zamy
(zamy)
February 23, 2015, 3:56pm
15
Meanwhile, thank you for your interest Moss
zamy
(zamy)
February 23, 2015, 4:07pm
16
The log category is declared in Union.h:
DECLARE_LOG_CATEGORY_EXTERN(LogUnion, Log, All);
zamy
(zamy)
February 23, 2015, 4:35pm
17
Aaaaaand that’s it.
in Union.cpp:
// Seemingly not used, because it doesn't compile!
//#include "Union.h"
//DEFINE_LOG_CATEGORY(LogUnion);
we have a log category non fully defined.
zamy
(zamy)
February 23, 2015, 4:43pm
18
So, i found out the problem:
Union.cpp is fully commented out, so we’re missing the Log category implementation.
In fact, adding the line
DEFINE_LOG_CATEGORY(LogUnion);
in my class cpp file allowed it to compile without errors.
I suggest to check out and fix the Union.cpp file.
zamy
(zamy)
February 23, 2015, 5:48pm
19
It doesn’t work even uncommenting Union.cpp
Then maybe remove the log category?
zamy
(zamy)
February 24, 2015, 3:09pm
20
Is there a way i can open a ticket, or it must be a staff member to open it?