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"

Problem about recursive inclusion

In my project, I need to include my class like below:


 #include "Tracer.h"


 #include "Loader.h"


 #include "Player.h"


 // Add Tracer as a scene component
 // Some code here


 //Trace Actor By Channel
 //part of the code
 if (GetWorld()->LineTraceMultiByChannel(HitResultArray, TraceStart, TraceEnd, ECollisionChannel::ECC_GameTraceChannel1, CollisionQueryParams)) {
     for (FHitResult hr : HitResultArray) {
         /*Found Loader*/
         if (hr.Actor->IsA(ALoader::StaticClass())) {
             // Do something


 void Loader::OverlapEnds(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex)
     if (OtherActor->IsA(APlayer::StaticClass())) {
         //Do something

However, this would cause recursive inclusion.

So, I try to add include guards to solve the problem.

But, I get an error "Error: UCLASS inside this preprocessor block will be skipped" if I add the include guards like below:


 #ifndef _LOADER_H_
 #define _LOADER_H_ 

 #include "Loader.h"



How should I solve the recursive inclusion problem in UE4?

Product Version: UE 4.15
more ▼

asked Mar 31 '17 at 06:13 AM in C++ Programming

avatar image

Jason Cheuk
11 2 4 6

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

1 answer: sort voted first

Hi. You can use interface class to break this include chain. For example make ILoader class with (and only with) virtual function set. You can read more about UObject interfaces here

As result you can get hierarchy like that:

  • ILoader includes nothing

  • Tracer includes ILoader

  • Player includes Tracer includes ILoader

  • Loader includes Player includes Tracer includes ILoader

  • And actual Loader is inheriteded from ILoader interface and implements it

more ▼

answered Mar 31 '17 at 10:14 AM

avatar image

1k 13 8 31

(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