Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Including a .h that also includes current .h

Is it not possible to include an .h that also includes that .h?

AFile.h includes BFile.h but BFile.h also includes AFile.h It is possible to have a UPROPERTY of type UAFile in AFile.h though...

Will I just have to work around this limitation?

Product Version: UE Github Master branch
more ▼

asked Sep 14 '18 at 06:24 AM in C++ Programming

avatar image

166 13 18 32

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

You can forward declare your classes, I'd look up a tutorial somewhere but here's the basics:

You can't include the .h files in each other, since that will cause a loop

You can however include them in the .cpp files.

Provided you don't need to interact with the classes from the other .h in your .h, you just need to create the variables, you can instead declare a class with the same name so the first class knows it exists


 //cant #include "BFile.h"
 class BClass;
 class AClass{
 BClass OtherClass;


 //cant #include "AFile.h"
 class AClass;
 class BClass{
 AClass OtherClass;

This way you can setup variables in your header as normal then make use of them by including the other header in your .cpp

more ▼

answered Sep 14 '18 at 09:57 AM

avatar image

1.4k 1 14 17

avatar image Althaen Sep 14 '18 at 01:44 PM

Doesn't seem to be working. The file I want to include has structures that I want to access. I don't know what I am doing wrong because it says it doesn't recognise the structure

avatar image HarryHighDef Sep 14 '18 at 01:58 PM

Can you show me what you are trying to do exactly?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

What you're doing is called a circular dependency and won't work. To compile the first class the compiler will need to know about the second which in turn needs to know about the first... As Harry mentioned you can used forward declaration, but to do this you need have only either pointers or reference to the other class, otherwise it won't change anything.

That's a complex issue which is usually a design issue, you should try to organize your classes dependencies differently. This thread on stack overflow explains all the ways to solve your issue, hope that helps!


more ▼

answered Sep 14 '18 at 03:58 PM

avatar image

1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question