Download

c++ #include error

Hi everyone, i was doing a c++ tutorial …
And once i added a code to my project, i selected the Actor option (wich was told me to do in the tutorial…)
I named it and created it successfuly.
But when i got into visual studio the


#include "Pickup.generated.h"

is already giving me an error. saying “cannot open source fille”

Also in the same page


UCLASS()
class TUTURIALTHIRDPERSON_API APickup : public AActor
{
	GENERATED_BODY()
	
	
	
	
};

The generated_body is also giving me an error saying “Expected an identifier”

That is all the code on the page , i havent done anything on the page yet. Is there any procedure i need to do , or anything ? ty

Just as a heads up:
the generated .H file is created when you build the project, it goes through your .H file and creates a bunch of meta-data things. If your class has any errors or issues, the generated file won’t be constructed. So, you have to fix those issues first in order for the file to be created…

The first thing I would probably look at is creating a publicly accessible constructor. Maybe that’s the issue?

To be more specific, only header tool errors (only interested in the stuff inside UPROPERTY, UCLASS, UFUNCTION, etc.) will prevent generation of the file. Plain compile errors happen after the header generation.

Actually i manage to remove the errors, but now in


class TUTURIALTHIRDPERSON_API APickup *:* public AActor

the : says expected declaration

any ideas ?
And thank you for the replys

Mate, this just solved mine. Maybe helps ??

Cheers :smiley:

well , looks like i got some bad luck … i followed ur steps, and noticed you copyed both cpp and header files from the guy that was helping you.
So i copyied as well . And still i got errors :confused: here is a printscreen c3ccba4d73e1add46c7a7c1f821c432b289f5d65.png

1st include is fixed , its just the name of the project that is difrent , but the rest is like u see

And also in the .H file i got this error f2ed0fbda6a90c0d3d8dba6e36c2b1050e0a0656.png

Yeah… so, the problem is that your project is named “TuturialThirdPerson” (which has a misspelling, btw). Mine was called “TutorialCode”.

When I created my project, the “tutorialcode.h” file was pregenerated and included in the project. You probably have a “tuturialThirdPerson.h” file somewhere. You need to change this. You have a few options:

A) Rename the “tuturialthirdperson.h” file to “tutorialcode.h”
B) Change your #include to your .H file
C) Create a new project called “TutorialCode” (to perfectly reflect the demo videos and avoid future translation mistakes)

What’s happening?
Well, the pregenerated file has:

Which means that it’s including all of the minimal features/capabilites of the engine. Since you aren’t including it, all of the engine capabilities you’re trying to use are unknown to the compiler and you’re getting the funky errors you’re seeing.

and also i know tuturial is misspelled, everything is tuturial for me (im not english easier :))

Btw what do you mean with
B) Change your #include to your .H file
I dont understand

Fair enough. Did you get the code to compile without errors after my suggested fix?

Sorry, that may have been a bit unclear.

You have a line at the top of your code which says: #include “TutorialCode.h” and that’s pointing to a file which doesn’t exist. Instead, you can change that to point to your header file by writing: #include “TuturialThirdPerson.h” which should exist (based off of the screenshots I saw).

ha ya , i noticed that and i actually changed it. And still gives me the errors…
Ill just create new project with same name as you ,and ill see if works
Thanks for the help so far everyone

hmm , ok so i made new project, followed tuturial , and copied ur code. most of things are goood only this now:


#include "Pickup.generated.h"

/**
*
*/
UCLASS()
class TUTORIALCODE_API APickup : public AActor
{
	GENERATED_BODY()

This is the error it self , the rest is good

Any idea ?

Your post came out malformed. Can you repost it with the code you’re using and the error messages you’re getting?

Thanks.

There has been some changes with the introduction of the GENERATED_BODY macro. If you want to follow the tutorial with no hassle, change GENERATED_BODY() to GENERATED_UCLASS_BODY().
Then you will use constructors etc. the old way, like the tutorials.

Without seeing more of your code, I can only assume that this is the cause…

Ok, here is the screen shot

and now this one

Also i have changed GENERATED_BODY() to GENERATED_UCLASS_BODY() and gives me the same errors :confused:

I think your header tool is trying to say something. It might be worth following its directives.

I just noticed , that everytime i create a new project (c++ code) , and create an actor i alway have errors , without changing anything.

Here is an example : b82f1c796e909177aa23c48fc5a3a3f870a139ee.png

Squiggles (i.e.: IntelliSense errors) are often wrong or out of date. While they are useful when they do work, don’t ever rely on them as actual “errors”. Compile the project and that will tell you if you do have any errors.

In this particular case, a freshly created class will not have a header generated since that happens on a full compile. So “Weapon.generated.h” being underlined is irrelevant until you compile first.