Originally posted by The-Cowboy
View Post
Announcement
Collapse
No announcement yet.
Is there a 4.22 C++ guide best practices somewhere?
Collapse
X
-
The-Cowboy replied
-
The-Cowboy repliedOriginally posted by Juice-Tin View PostFew things that may help:
1. In the .h files you usually don't need to have other header includes. If you're using other classes you can use 'class' in front to forward declare it.
Ex:
Code:UPROPERTY() class AUTGameState* GameState;
Originally posted by Juice-Tin View Post3. Cached problems! Somethings things just don't work even though they should. Usually worth doing a full rebuild of the project, or deleting the intermediate folder, regenerating project files (right click the .uproject file) and rebuilding the game.
This could fix odd compiler/game errors that just don't make sense (possibly the spacing errors).
Leave a comment:
-
Juice-Tin repliedFew things that may help:
1. In the .h files you usually don't need to have other header includes. If you're using other classes you can use 'class' in front to forward declare it.
Ex:
Code:UPROPERTY() class AUTGameState* GameState;
2. If you ever try using something like FTableRowBase and notice bogus linkage or 'not found' errors, google it and the page will show the following:
- Which header to include in the .cpp
- Which module name to add to your publicdependencies in ProjectName.Build.cs
3. Cached problems! Somethings things just don't work even though they should. Usually worth doing a full rebuild of the project, or deleting the intermediate folder, regenerating project files (right click the .uproject file) and rebuilding the game.
This could fix odd compiler/game errors that just don't make sense (possibly the spacing errors).
Leave a comment:
-
The-Cowboy repliedOk equivalent problem. In UTGameState.h the following directives are fine
Code:#pragma once #include "UTPlayerState.h" #include "UTCharacter.h" #include "ChartCreation.h" #include "UTGameState.generated.h"
Code:#include "UTLineUpZone.h"
Code:incomplete type 'AUTGameState' in nested name specifier
I tried all possible permutations in the list but of no avail. Curiously it doesn't even matter if I comment out the last directive, it is as if it is counting the number of lines.
Finally the code
Code:#pragma once #include "UTPlayerState.h" #include "UTCharacter.h" #include "ChartCreation.h" #include "UTLineUpZone.h" #include "UTGameState.generated.h"
Last edited by The-Cowboy; 06-06-2019, 10:37 AM.
Leave a comment:
-
The-Cowboy repliedHi Zhi, thanks for the interest. I will post the error in the next cycle of building process (the project is too global and the error spits are overwhelming!).
Leave a comment:
-
Zhi Kang Shao repliedCan you share the errors? Because code-wise that should be the same, however know that UE4 has a feature called Unity Build (not to be confused with Unity engine) that combines source files before compiling. That reduces compilation times for larger projects, but it there are two things to be aware of:
* You never know which files are going to be combined before compiling, small changes (such as a space) may cause files to be combined in a different way
* The files being combined will often mask the fact that some of your code is missing includes.
For example if a source file of yours is using the class MyClass and it's not being included, that's an error in your code right? But unity build may be combining that file with another file that does include MyClass.h and your project will build fine, unless some small changes causes files to be combined in a different way and the error surfaces.
That's the only explanation that I can think of for why a newline is the difference between error and no error for you.
Leave a comment:
-
The-Cowboy repliedOk, I should take that for face value I guess. Things get even more weird. Has anyone noticed the thing about white spaces? For instance the practice of writing
Code:#pragma once #include "UTWeaponAttachment.h" #include "UTWeapAttachment_ImpactHammer.generated.h"
Code:#pragma once #include "UTWeaponAttachment.h" #include "UTWeapAttachment_ImpactHammer.generated.h"
Last edited by The-Cowboy; 06-04-2019, 08:15 PM.
Leave a comment:
-
nilamo repliedThere's more in there for more complicated things, like Replicated variables or Blueprint callable functions. For an empty class, it should basically be nothing except reflection info.
Leave a comment:
-
RickBlacker repliedI don't know the specifics but I do know that I've been watching video tutorials and they have said the same thing. Nothing below the .generated. file.
Leave a comment:
-
The-Cowboy repliedCould you be more specific about the glue part? For instance the Party.generated.h looks like
Code:// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. /*=========================================================================== Generated code exported from UnrealHeaderTool. DO NOT modify this manually! Edit the corresponding .h files instead! ===========================================================================*/ #include "UObject/ObjectMacros.h" #include "UObject/ScriptMacros.h" PRAGMA_DISABLE_DEPRECATION_WARNINGS #ifdef UNREALTOURNAMENT_Party_generated_h #error "Party.generated.h already included, missing '#pragma once' in Party.h" #endif #define UNREALTOURNAMENT_Party_generated_h #define UnrealTournament_Source_UnrealTournament_Public_Online_Party_h_116_RPC_WRAPPERS #define UnrealTournament_Source_UnrealTournament_Public_Online_Party_h_116_RPC_WRAPPERS_NO_PURE_DECLS #define UnrealTournament_Source_UnrealTournament_Public_Online_Party_h_116_INCLASS_NO_PURE_DECLS \ private: \ static void StaticRegisterNativesUParty(); \ friend struct Z_Construct_UClass_UParty_Statics; \ public: \ DECLARE_CLASS(UParty, UObject, COMPILED_IN_FLAGS(0 | CLASS_Config), CASTCLASS_None, TEXT("/Script/UnrealTournament"), NO_API) \ DECLARE_SERIALIZER(UParty) \ static const TCHAR* StaticConfigName() {return TEXT("Game");} .... PRAGMA_ENABLE_DEPRECATION_WARNINGS
Leave a comment:
-
ExtraLifeMatt repliedOriginally posted by The-Cowboy View PostWhy is so? And what is the utility of ".generated.h" files?
- 2 likes
Leave a comment:
-
The-Cowboy repliedOriginally posted by nilamo View PostThe ".generated.h" file needs to be the last include file,
Leave a comment:
-
nilamo repliedThe ".generated.h" file needs to be the last include file, anything else you include should happen before that. I'm not sure what other help I can give without seeing the build errors.
Leave a comment:
-
The-Cowboy repliedLet us just say that writing about proprietary software is not my "cup of coffee"!
Leave a comment:
-
RickBlacker repliedOriginally posted by The-Cowboy View PostI am in the process of writing a decent guide for setting up QT Creator for the Engine in Linux.
Leave a comment:
Leave a comment: