Announcement

Collapse
No announcement yet.

Question about the C++ documentation

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

    Question about the C++ documentation

    I am following along with some of the C++ documentation and in one part I need to use UCameraComponent. In the documentation the code does not contain

    #include "Runtime/Engine/Classes/Camera/CameraComponent.h"

    yet it only compiles when I add that line. Why is this?

    #2
    Not sure which documentation you are looking at so cannot comment on whether there is an error there but in the engine source code the UE4 class structure is all located in the Runtime/Engine/Classes folder in individual .cpp files. To "get access" to the code for a particular class you need to #include the header for that class in your code.

    You don't need to crawl through the engine source code to find this out, it is documented at the bottom of the C++ API documentation for each class:

    UCameraComponent entry: https://api.unrealengine.com/INT/API...ent/index.html

    "Root" of the C++ API documentation: https://docs.unrealengine.com/en-US/API/index.html (to use the Search effectively, type in the class you are looking for and then in the search results select the C++ API filter that will appear just below the search field after you run the search).

    Comment


      #3
      If there is an error in the Epic documentation, post it here so it can be fixed- https://forums.unrealengine.com/unre...-new-docs-site

      Comment


        #4
        Originally posted by ssplayer View Post
        I am following along with some of the C++ documentation and in one part I need to use UCameraComponent. In the documentation the code does not contain

        #include "Runtime/Engine/Classes/Camera/CameraComponent.h"

        yet it only compiles when I add that line. Why is this?
        The Samples were written before an update required "Include What You Use" (IWYU), so previously you didn't need to include that file because it was included elsewhere. There was a change to improve compile times that cleaned up a lot of those references, but now you have to explicitly include what you are using. So, because you are using a CameraComponent, you must include the file for it manually.
        Able Ability System - A high performance, robust ability system for UE4. Now Available!

        Comment


          #5
          You don't even need to necessarily include:

          #include "Runtime/Engine/Classes/Camera/CameraComponent.h"

          Either just this:
          #include "Camera/CameraComponent.h"

          Or this:
          #include "CameraComponent.h"

          Should work.

          Comment


            #6
            Originally posted by illYay View Post
            You don't even need to necessarily include:

            #include "Runtime/Engine/Classes/Camera/CameraComponent.h"

            Either just this:
            #include "Camera/CameraComponent.h"

            Or this:
            #include "CameraComponent.h"

            Should work.
            Yeah I tried that but it is not working

            Comment


              #7
              I think eliminating parts of the path only works if you have set corresponding environment variables (or some other build script) in Visual Studio so the compiler can find the header. Otherwise, I don't think compiler will find the header.

              Comment


                #8
                like @MCX292 said, name of the header is at bottom of doc page
                https://www.casualdistractiongames.com

                Comment

                Working...
                X