UE5.4.2 C++ Project Build Fails After Any Change

Someone please save my life!

I’ve encountered a persistent issue where my C++ project fails to build if I make any changes to certain custom C++ files (make no changes will successfully build and run), even something as minor as adding a whitespace or a new blank line. Additionally, the build fails if I change the encoding of these custom C++ files from GBK to UTF-8.

Here are the steps I’ve tried to resolve the issue:

  • Cleaned and rebuild the solution
  • Regenerated Visual Studio project files
  • Attempted to build using both Visual Studio 2022 and Rider
  • rollback or revert to previous version

Despite these efforts, the build continues to fail under the conditions mentioned above. Has anyone experienced similar issues or have any suggestions on how to resolve this?

Hi!

Can you share error message, please?

Hi,

I just find what causes the issue but I do not understand what is behind the issue.
I have some code in old versions like:

TSubclassOf<GameplayAbility> StartupAbilities
or
TArray<FActiveGameplayEffectHandle> ActiveEffects

But I never include “Abilities/GameplayAbility.h” or “ActiveGameplayEffectHandle.h” and I can still build successfully and run the project with old version. Now I have upgrade UE from 5.3.2 to 5.4.2 I got error like:

11>BaseCharacter.h(89): Reference C2923 : 参见“UGameplayAbility”的声明
11>BaseCharacter.h(89): Error C3203 : “TSubclassOf”: 未指定的 类 模板 不能用作 模板 参数 “InElementType” 的 模板 参数,应为真实类型

I am stupid because I never thought it just because I need include some .h file. I don’t understand what’s happening here, could you please briefly explain this to me?

By the way I don’t know why my output has Chinese, I want to change the output to English.

Thanks!

Did you add the GameplayAbilities module into your build file into the dependencies?

InElementType probably refers to a class that is either not forward declared or lacks the proper include for it’s definition.

If there is no include regarding the class then the compile just doesn’t know what the parameter is and won’t compile correctly.

And InElementType cannot be a template class.

Hi,

I did not add “Abilities/GameplayAbility.h” or “ActiveGameplayEffectHandle.h” to my files, that is the reason I build fail on my current version. But the real question is my previous version also does not include “Abilities/GameplayAbility.h” or “ActiveGameplayEffectHandle.h”, but it will just build successfully.

Thanks!

is you have

TSubclassOf<GameplayAbility> StartupAbilities
or
TArray<FActiveGameplayEffectHandle> ActiveEffects

then you need the to include the headers for GameplayAbility and FActiveGameplayEffectHandle and their module.

Look at the uneal c++ documentation

Check the Include and module for both