Cannot Call an Enum from Another Script, Reads as Int Despite Correct Classifcation as Unt8

Greetings, I am having significant trouble diagnosing this error, as I simply don’t know what’s causing the problem and would greatly appreciate any insight.

Context: I am building a procedural generation script. Declared Enums as part of a separate Enums.h file (with an empty Enums.cpp, don’t know if that’s an issue), then I am attempting to call an enum called in that file “EBlock” in my new script, GreedyChunks.h.

Error: Before, I had it defined in Enums.h simply as “enum class EBlock”, no UENUM, no uint8. But then I needed to change it an UEnum to allow to be used in a UFunction. However, upon doing this, my call in GreedyChunks.h now doesn’t work.

"GreedyChunk.h(12): error C3433: ‘EBlock’: all declarations of an enumeration must have the same underlying type, was ‘unsigned char’ now ‘int’ "

Here is my Enums. h file, very short and simple:

And here is my current GreedyChunks.h layout, also short enough:

I have tried redefining EBlock outside of the struct, in a public declaration, using TEnumsAsBytes, and have rebuilt, cleaned, and deleted/regenerated the project files several times, always coming up with the same error which cascades everything else.

I reference EBlock a LOT in my code, since I’m not only using it to decide which block types go where, but also to feed in information during for loops while generating the mesh. I can change the name, the type, whatever is needed, but I don’t even know where to begin with this error and I’ve scoured the internet for references and fixes to no avail. While I understand coding quite well, I am still fairly new to C++ so I might be missing something obvious or otherwise unique to the syntax/structure. I just don’t know unfortunately.

Does anyone have any ideas, insight, or otherwise can help with this situation? It would be very appreciated.

Good news, I actually managed to find the problem very shortly after posting this.

The issue lied with an old file I had forgotten about. I had recreated my GreedyChunk file and renamed it GreedChunks, as I was making edits and wanted to keep the old working version.

I forgot about it, and thus didn’t realize it was throwing an error because it defined “enum class EBlock”, which is exactly what we didn’t want. Because it had such a similar name, I kept thinking my newer file was making the mistake.

Thankfully, once this script was removed from the project, the newer one is working just fine now, so the code posted is actually fully functional, just an oversight on my part.

If you have a similar issue to this, I hope this could possibly point you in the right direction, you never know what you’ve forgotten to account for file wise.

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