Dear Friends At Epic,
I have a core class that is a Uobject that has all my defines and USTRUCTS in it that need to be used project-wide
I want to add more #defines and more USTUCTS to this 1 core class via a .h header file containing its own set of #defines and USTRUCTs
This is just for organization
Currently the only method I know is to make my core UOBJECT class extend other super classes that have the other specific #defines and USTRUCTS
Is there a way to just include a .h file that has no corresponding .cpp?
what I’ve tried
I tried just creating a MoreDefinitions.h and adding the MoreDefinitions.generated at the top and including it in my core UOBJECT class
but I get the compile error that the MoreDefinitions.generated could not be found
thanks!
Rama
Rama, is your file in the Classes folder, or in Private?
I think we’ve found that anything in Classes expects a special MoreDefinitions.h like that, so you have to put such header files in Private in order to get around that restriction.
Hey that was brilliant!
When I put the .h file in the Public folder it worked!
Thanks Neil and Mothership!
Rama
I think it should be in Private … but glad it worked all the same
It did not work in Private, said the file could not be found.
You’re almost right, just get rid of MoreDefinitions.generated.
In your UObject header, make sure you do:
#include "MoreDefinitions.h"
before
#include "YourUObject.generated.h"
And that should work. I’m doing this!
Example of how it may look:
// Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "MoreDefinitions.h"
#include "YourUObject.generated.h"
UCLASS()
...
when I tried to compile without the .generated, I got a compile error saying it was looking for a .generated
Again the structure was
MoreDefinitions.h
#pragma once
#define SOME_DEFINITIONS 1
then the core object class:
CoreObjectClass.h
#pragma once
#include "MoreDefinitions.h"
#include "CoreObjectClass.generated.h"
the compile error was for MoreDefinitions.h saying it wanted a .generated
Rama
What are the entire contents of your MoreDefinitions.h header file?
Are you using the UCLASS macro (or any other macro) in it?
I just tried this, for example, and this compiled for me:
// Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
#pragma once
#include
#include "Tile.generated.h"
(where “Tile” is the name of my UObject derived class). Obviously is a standard header - but this works!
Soumik_25
(Soumik_25)
March 12, 2018, 3:26am
9
private is only for .cpp files all .h files is on public folder