Forward Declarations Break TankAIController (Won't Compile)

I’ve followed the updates in adding forward declarations and find they’ve broken TankAIController. It now will not compile. Here is a snip of the compile error log:

As you can see, ATank is not recognized, this despite a forward declaration in TankAIController.h and #include of Tank.h in TankAIController.cpp. Here is a snip of #includes in the .cpp file:

If I hover above the Intellisense error line for the first #include, the error states that source file TankAIController.h can not be opened though a window in VS with that file is open right next to it. When entering the #include for that line, Intellisense only suggests the generate file, not the .h file.

Here’s the #Includes from TankAIController.h as well as the tabs showing the two realted files open in the IDE.`

I’ve reverted and retried the code changes and this file continues to fail. I must be missing something on this, but I can’t see it.

Are you using the Public/Private folders? If you are, try including “Public/TankAIController.h” instead. I think something changed in the Unreal/Visual Studio versions after the video was made, regarding include paths.

I don’t guarantee that’ll help, but it did fix similar issues for me in the past.

Thanks. I gave that a try and get the same errors. Something else is happening. Grrr.

Following the Intellisense error to ground, I right-click it then open the source file and see that it is trying to look in a different directory for the header file than the one in which the header file actually sits. The header file lives in the Public folder with all of the other tank component header files. But Intellisense thinks it should be in the Private folder. Very weird. None of the other header files produce Intellisense errors in their respective cpp files

Retried adding Public - Intellisense error is gone but the compile errors persist.

The errors near the bottom are interesting, about how some of the methods are re-defined, or have the wrong signature. Could you share both the .cpp and .h, the entire files? Maybe there’s an issue with the contents of the header file that’s leading the compiler to not understand…

Sure. Adding both. Weird they worked before the forward decl arations which are the only changes. (1.0 KB)

I finally found the issue. In the forward declaration for ATank, I type is Atank. Then, in the cpp file, I typed it ATank. Cases didn’t match, so files didn’t link properly.

Thanks for taking a look at it. Capitalization is one of the issues that’s sometimes hard for me to spot.

I was just about to say that :stuck_out_tongue:
Also, in the .cpp file, your Tick isn’t prefixed with the class name.

You have: void Tick(float DeltaTime), but it should be: void ATankAIController::Tick(float DeltaTime).

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms