'variable FString is not a type name' in HiddenWordList.h (VS2019)

Hi guys,

I’m getting this error after adding the HiddenWordList header file in the BullCowGame project. I’ve added in in Source/BullCowGame which is where it’s added in the course.


I’m also getting ‘cannot open source file “HiddenWordList.h”’ in BullCowCartrdige.cpp - even when commenting out the Words array with the previously mentioned error:

image

I’m using VS 2019 Community.

Thanks.

Does it compile in UE4? If so then it’s an IntelliSense issue.

If not, then I’m not sure how TArray is usable but FString isn’t.

Yeah, it fails in UE4 too:

Creating makefile for BullCowGameEditor (game project files are newer)
Building BullCowGameEditor...
Using Visual Studio 2019 14.25.28614 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
[Upgrade]
[Upgrade] Using backward-compatible build settings. The latest version of UE4 sets the following values by default, which may require code changes:
[Upgrade]     bLegacyPublicIncludePaths = false                 => Omits subfolders from public include paths to reduce compiler command line length. (Previously: true).
[Upgrade]     ShadowVariableWarningLevel = WarningLevel.Error   => Treats shadowed variable warnings as errors. (Previously: WarningLevel.Warning).
[Upgrade]     PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs   => Set in build.cs files to enables IWYU-style PCH model. See https://docs.unrealengine.com/en-US/Programming/BuildTools/UnrealBuildTool/IWYU/index.html. (Previously: PCHUsageMode.UseSharedPCHs).
[Upgrade] Suppress this message by setting 'DefaultBuildSettings = BuildSettingsVersion.V2;' in BullCowGameEditor.Target.cs, and explicitly overriding settings that differ from the new defaults.
[Upgrade]
Building 4 actions with 16 processes...
  [1/4] BullCowCartridge.cpp
  E:\Learning\Unreal\Unreal C++ Course\BullCowGame\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(3): fatal error C1083: Cannot open include file: 'HiddenWordList.h': No such file or directory

Now that’s a very different error than FString not being a valid type, where is your hidden word list header file located? Because UE4 can’t find it.

FYI I used a seperate word list text file to reduce compile times thanks to this post:

If nothing else works (or if you want a more efficient method), just place a text file of the words each on their own line and add this to the start function of the BullCowGameCartridge.cpp file (note: you’ll also need a member variable of type TArray<FString> in the header file (not the word list one, you can delete that if you use this method) called WordList.

const FString WordListPath = FPaths::ProjectContentDir() / TEXT("WordLists/HiddenWords.txt");
FFileHelper::LoadFileToStringArray(WordList, *WordListPath);

You can change the path to anything you want just make sure it’s inside the project’s content folder (the path in the text macro is relative so for example if your content folder was C:\PathToProject\BullCowGame\Content, then Test inside the text macro would resolve to C:\PathToProject\BullCowGame\Content\Test).

In my original post, you can see that my HiddenWordList.h file is in Source/BullCowGame which is where it’s placed in the course. I also mention that I’m getting this second error there too.

Hmm, if you can’t or don’t want to implement the text file word list, are you able to zip a copy of your project and post a link to it here using something like Dropbox, Google Docs, or OneDrive? (not certain if OneDrive supports file links but I would assume so)

Another thing to try is using an absolute path name for the include instead of relative.

OK, I think I’ve sorted the issue with the HiddenWordList.h file now. For some reason, when I right click a folder in Visual Studio and choose Add New Item..., the default location was set to Intermediate/ProjectFiles for whatever reason. I obviously didn’t notice this when I first added the file and the solution explorer was showing it in the Source/BullCowGame folder so it looked like it was in the correct location - it wasn’t! I just deleted and re-added it in the correct folder and it seems to be building and compiling successfully now.

Interestingly though, despite the fact that it builds successfully, I still get the red squiggly line under FString with the same error about it being a variable but not a valid type… Is this just VS being weird?

image

Yeah, IntelliSense can be like that some times, especially with external libraries like Unity’s and Unreal’s.

1 Like

Thanks @100PixelsSquared. Your suggestion about changing to an absolute path was what actually helped me discover this issue as when I went to find the file in Windows Explorer, it wasn’t where I expected it to be!

1 Like

Happy to help!
Please mark one of my posts that is the closest to the solution as a solution so the topic gets auto closed rather than auto bumped.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms