UENUM issues in 4.11

Hi

I followed the tutorial c++ project “Battery Collector” in version 4.10 with no problem. I upgraded to UE4.11 and could convert the project from UE4.10 to UE4.11 with no problem.

However, if I start the project from scratch in UE4.11, I have a problem when adding a Enum code. Check both screenshots.

Unreal 4.10 (no problem):

Unreal 4.11 (problem):

The code is exactly the same in both projects. I’ve tried also adding enum class EBatteryPlayState : uint8 in the Enum definition, but still the same problem.

There is another post talking on UPhysicsHandleComponent class that suddenly gives problems when declaring it in Unreal 4.11. You can check it: UPhysicsHandleComponent and ATriggerVolume issues - C++ - Epic Developer Community Forums

For some reason some things are stopping working in 4.11. I’ve checked the [Unreal Engine 4.11 Released!][3] post, and there is this entry: “Bugfix: Fixed hot reload crashes that were occuring when user added C++ enums to the code.”

Is any of you having this issue or is able to reproduce the issue?

Specs: Unreal 4.11 Windows 10 Home - OS Build 10586.164 NVIDIA GeForce GTX 960 - Driver version 364.72

Visual Studio Community 2015 v14.0.25123.00 Update 2

1 Like

Hey,

Have you tried deleting your Intermediate folders and rebuilding? This looks like a case of old generated code.

I also notice that the first error is in the .cpp file, not the header.

Steve

Hi Steve

Thanks for your reply.

The error you see in the .cpp file is this:

Deleting Intermediate and rebuilding doesn’t work either.

I made another test by creating a First Person C++ template project from scratch. Then I added the enum code, and get this:

gamemode.h

gamemode.cpp

Surely it should work like a charm without the need to hack all the way out. You may be able to reproduce the issue. Can you confirm?

Can you post your build output? The CPP errors are most likely just because of the header errors, and the header error from the error dialog is not really useful for figuring out what in the UCLASS macro is going crazy.

I’ve tried it in our latest code (create new C++ First Person project, add enum to NewProjectGameMode.h, compile) and it was fine.

I’ll try it on the 4.11 release, but I’m not going to be able to do it right now.

Steve

Well, I did some tests. There are inconsistencies both in VS and the Editor.

If I try to compile a couple of times, it will compile without errors eventually (no changes made on the code). When this happens, the compile button disappears from the editor.

In the Test Project, although it gives no error on the output, the error list shows errors:

Output:

Error List (but compiled ok):

Regarding the new Battery Collector project, I also get inconsistencies. After several failed builds, it eventually compiles ok (the compile button disappear in the Editor, though):

At first I got errors:

After a couple of tries (without changing anything in the code), it compiles successfully:

However, the Compile button dissapears from the editor:

I don’t really know what might be causing this issue.This is far from ideal as it bogs you down for no particular reason.

Update: I tried to compile again, I got errors. I didn’t change anything since last successfull build. Very inconsistent behavior.

1 Like

I’m having the exact same errors, I created an Enum in the same file where I created a class ( an ActorComponent), and it doesn’t compile. I’m using Unreal 4.11.1

1 Like

4.15 still same issue, btw this may be related to VS2015 saying, that files “need to be saved in unicode encoding (some characters are not supported in current character encoding)” because the issue appeared when i added Enum to my project, and at the same time editor began “worrying about character encoding” (it did not earlier).

The behaviour is consistent - it’s just that in your ‘it compiled’ case, you were attempting to compile while there was an editor running. UE interprets that as a request to hot reload (see the comment in the output: “Compiling game modules for hot reload”) rather than a proper build. You should never attempt a normal build while a editor instance is running.

Steve

There are several issues posted on this page - which ‘same issue’ are you referring to?

If it’s the “name followed by ‘::’ must be a class or namespace name” error, then that suggests a missing #include, or possibly two headers with the same name and it’s including the wrong one.

Steve

i was speaking about the main thread’s issue (first post). Whenever you add UENUM to a header file, editor will make A LOT of different errors, that are not because of a badly written syntax errors (its written same, as in the official tutorial, the “C++ Battery Collector”)

I even loaded a different project of the same tutorial that i successfully finished several months ago (for UE 4.10 - 4.12 or similar) it now fails to compile with exactly same issue. (in the past it was compiling and working without errors).

Update:
i probably found the cause of the issue, i will retry reproducing/fixing once again tomorrow and report soon.

i didn’t try to compile with UEditor being closed (rather than just alt-tabbing), so i dont know if it is the case (maybe i will test it later), but anyway, i didn’t know, there is that difference between these 2 compiling circumstances.

It’s not intended anyway (the video tutorial does not offer to completely close the UEditor window in case, that error happens).

If it will help, then i will post my answer as a working workaround for the issue, after testing it tomorrow.

Resolved. (admins can now put the “Resolved” mark on this topic)

  1. The first thing that needs to be fixed is the “uint8” enum type. (after 4.11+)

For example in tutorial you will need to replace the

enum class EBatteryPlayState

with

enum class EBatteryPlayState : uint8

This is the reason, that makes IntelliSense being crazy and making all the class methods unrecognizable. For this reason it displays, like 20-30 errors, where it was actually just a single syntax error. Thats the reason why it is hard to find and fix, you just should ignore all the errors related to uclass, it’s namespace or methods and look thorough a whole list of errors, among those 20-30 “fake errors” there are 1-2 real error that break syntax and eventually generate those 20-30 fake errors. Again - dont try to fix them, (most of them are fake), you only need to look at those errors that are not related to Class and fix a single (and the only real) syntax error, that broke the whole Class.

  1. personally i had 2 more real errors, when a copied the getter and setter for the PlayingState enum, i forgot to rename method’s name according to my project’s name. At this point Visual Studio already displayed like 30 errors, hiding only few real errors, among all of them.

EDIT:

its already mentioned in youtube video’s comments about the “uint8” enum decalaration.

EDIT2:

About header file and IntelliSense.

adding uint8 to enum declaration (and fixing all other mentioned errors as well) will not fix the whole class right away, IntelliSense may take some time and even few minutes later it may not get rid of those errors, i have added a “;” (2 of them in a row, one of them is excessive) into the GameMode.h file right after Enum’s closing bracket, then i saved that file and tried to Build project, after that i removed that excessive “;” and only 30-60 seconds later IntelliSense finally fixed those 30 unexisting errors and after that Build worked successfully. Sometime it may not help, so it is better to restart the Visual Studio to get rid of those errors (restarting works better, more likely to clean those errors from the error log).

Even removing some empty lines between enum and a class declaration, will “summon” a bunch of

“name followed by ‘::’ must be a class or namespace name” and

“a type qualifier is not allowed on a nonmember function”

so those errors are hard to get rid of, once they appear. But anyway compiling goes successfully. So IntellySense errors in such case can be ignored.

In Visual Studio at the bottom there an error log (which displays, IntellySense Error and Build Errors, if i enable “IntelliSense + Build” option, then it will display errors, but in “Build Only” (error filter) then log frame displays none errors, so IntelliSense definitely is bugged at recognizing class declaration in header file whenever some empty lines are added or removed above the class.