Visual Studio Code error

dacd2f4d3aef33d04d7569fdad509134b1b514d0.jpeg

Hello, I start in C ++ in unreal with VS2017. But VS2017 does not accept some code :s
I do not know what to do.
I went into the file “edit” “preference” and took vs2017.

Do you get an error when you try to compile? because Visual Studio doesn’t understand a lot of UE4 code and so has the red squiggly lines a lot that aren’t problems :slight_smile: - try to compile

Try adding the header:

Runtime/Engine/Classes/Components/BoxComponent.h

Of course you need to include the headers for classes you’re using.
in your *.h file add the following line (before your own class) :


class UBoxComponent;

This is a forward declaration (you should not include headers in your own .h when it’s not necessary)

in your *.cpp, add the following line:


#include "Runtime/Engine/Classes/Components/BoxComponent.h"

This is your actual include which makes your cpp “ready” to use external classes.

Hi,
my VS2017 It says: unable to open the source files for the
#include “Runtime/Engine/Classes/Components/BoxComponent.h”
and yes, the error is there when i try to compile

The include is incorrect, try this :


#include "Components/BoxComponent.h"

And the forward declaration in the header is not for the UBoxComponent, but the UShapeComponent

:rolleyes: people acting like everyone knows that Epic changed the system to include what you use… MinimalCore :frowning: … RIP Engine.h… You’re probably going to need to add staticmeshcomponent.h as well, although I’m not sure what is in CoreMinimal or Actor.h :confused:

Edit: also you have a UShapeComponent as variable root in your header, wouldn’t it be better to be a UBoxComponent? I know UBoxComponent inherits from UShapeComponent but I guess it depends what you’re doing.