x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

C++ Why are files put in the Intermediate folder?

I see in my [GameName]Classes,h file is reads, do not modify, how to you add your header files to your .cpp files. Looking in ShooterGame, most ,ccp seems to point to ShooterGame.h but some of them follow the C++ convention I'm more used to and point to a header file of the same name.

How are new headers added to this list if you are not supposed to modify it?

Also, is it a bug that all new .h and .cpp files made in VS go into the Intermediate Folder? Should they be moved into a folder structure that mirrors the filter structure in the Solution Explorer?

Product Version: Not Selected
Tags:
more ▼

asked Mar 11 '14 at 02:05 AM in C++ Programming

avatar image

ue4-archive ♦♦ STAFF
50k 3669 1999 9123

avatar image DamerDy Sep 30 '17 at 04:04 AM

Can you give me a video,i still confuse

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

When you're creating new C++ classes in Visual Studio, you'll need to take note of where they're placed. You definitely do not want to save them under the Intermediate folder. That will only lead to sadness. Here is the general idea:

  • If you plan you declare UObjects or UStructs in your header file (.h), you'll need to make sure its saved under the Classes sub-folder for your game module. This is so that UnrealHeaderTool will be able to locate these headers, parse them, and automatically generate additional C++ code for those classes. For example:

    /Source//Classes/MyUObject.h

  • Most of your other non-UObject C++ header files (.h) should go in your module's Private folder. This is just where we put source files and headers that aren't exposed to other (sibling) modules.

    /Source//Private/MyGameFeature.h

  • All of your game's C++ source files (.cpp) should go into your module's Private folder. Source files are never "public".

    /Source//Private/MyGameFeature.cpp

  • You may decide to use multiple C++ modules (.dll's) for your game. If you do, then you can place classes in a Public folder to allow your game module's sibling modules to access those APIs, or vice-versa. This is a more complicated use case that I can elaborate more on if you want. Also note that currently, all files in the "Classes" folder are also considered Public, even though most of the time they will only be used in the module that declared the class. An example of a publically exposed header would be:

    /Source//Public/MyPublicAPI.h

Let me know if you have any more questions like this!

--Mike

more ▼

answered Mar 11 '14 at 02:05 AM

avatar image

ue4-archive ♦♦ STAFF
50k 3669 1999 9123

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:05 AM

Wonderful answer Mike, it helped clear up a lot of my confusion.

Thank you.

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:05 AM

It's really easy, actually! For every *.Build.cs file that you create, UnrealBuildTool will automatically generate a DLL for that module. So you can create a new module by copying an existing Build.cs file and renaming/editing it appropriately, then adding source files into the new module's Source directory.

Next time you generate project files, that module's source will be discovered by UnrealBuildTool and added to your solution. Similarly, when you build your game project, as long as another module has a dependency on your new module, it will be built along with your game.

You create a dependency on your new module by modifying your game module's Build.cs file. You can add your new module's name to your game module's PrivateDependencyModuleNames array. This will also automatically make the public header files in your new module available to be included in the game module. This is just one example of setting up a module dependency, there are other ways to do it -- our build system is very flexible!

I should mention that we don't really expect games to be built out of multiple modules very often. If you choose to do this it will be a more work for you and your team members. This is because programmers will need to create interfaces to access subsystems implemented in outside modules instead of just going straight to the code directly. You can argue the resulting code might be cleaner this way, but it may slow down your ability to iterate on code quickly.

Just for some context, our internal Fortnite game currently only has 3 game modules. However, we use dozens and dozens of interdependent modules for the game engine itself.

Hope this helps!

--Mike

avatar image rhm Dec 21 '14 at 11:51 PM +

None of this explains why Visual Studio always has the intermediate folder as the default location when you go to add a new file (which is the source the OP's confusion). What is so peculiar about the project files UE4 generates that VS does this?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I made folders and moved the files into a windows structure that mirrored the CS filter structure.

I found that when building from VS, the new header class was added to the MyGameClasses.h

more ▼

answered Mar 11 '14 at 02:05 AM

avatar image

ue4-archive ♦♦ STAFF
50k 3669 1999 9123

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:05 AM

It looks like headers that go into the Classes folder get a generated header but headers put into the Private folder do not. Classes extending Slate stuff appear to go into the Private folder.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question