Announcement

Collapse
No announcement yet.

c++ #include error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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
    Code:
    #include "Pickup.generated.h"
    is already giving me an error. saying "cannot open source fille"

    Also in the same page
    Code:
    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

    #2
    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?

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

    public:
    APickup(const FObjectInitializer& ObjectInitializer);


    };

    Comment


      #3
      Originally posted by Slayemin View Post
      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...
      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.

      Comment


        #4
        Actually i manage to remove the errors, but now in

        Code:
        class TUTURIALTHIRDPERSON_API APickup : public AActor
        the : says expected declaration

        any ideas ?
        And thank you for the replys

        Comment


          #5
          Mate, this just solved mine. Maybe helps ??

          https://forums.unrealengine.com/show...orking-Wit-4-6

          Cheers
          ArtStation

          General Development Blog

          Comment


            #6
            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 :/ here is a printscreen Click image for larger version

Name:	erro1.png
Views:	1
Size:	106.2 KB
ID:	1062219

            1st include is fixed , its just the name of the project that is difrent , but the rest is like u see
            Last edited by Folgad0; 12-16-2014, 07:34 PM.

            Comment


              #7
              And also in the .H file i got this error Click image for larger version

Name:	erro2.png
Views:	1
Size:	111.6 KB
ID:	1062220

              Comment


                #8
                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:
                // Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

                #ifndef __TUTORIALCODE_H__
                #define __TUTORIALCODE_H__

                #include "EngineMinimal.h"

                #endif
                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.

                Comment


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

                  Comment


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

                    Comment


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

                      Comment


                        #12
                        Originally posted by Folgad0 View Post
                        Btw what do you mean with
                        B) Change your #include to your .H file
                        I dont understand
                        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).

                        Comment


                          #13
                          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

                          Comment


                            #14
                            hmm , ok so i made new project, followed tuturial , and copied ur code. most of things are goood only this now:
                            Code:
                            #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 ?

                            Comment


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

                              Thanks.

                              Comment

                              Working...
                              X