Download

EUnitType Prevents Compile After Adding New CPP Class [SOLVED]

Hi all,

Recently I tried to add a new c++ class to my project, which inherits from a custom AActor class I’ve made. I do, already, have several other custom c++ classes inherit from this class with no issues.
The Problem:
When adding the new class using the in Engine Window the project no longer compiles, giving me the following error:


This is Engine code, which is set to ReadOnly for me.
This is the section at which the error occurs:

What I’ve Tried:

  • Searching for another declaration of EUnitType, I was not able to find one
  • Creating the c++ class with a different name; this has no effect
  • Creating a new c++ class in a starter project; this works fine.
    Note:
    When I delete the newly created class’ files, the project compiles again.

Any help is greatly appreciated!
Best.

Edit:
logs:

After tying some things, I found a new new error that appears in Visual studio before the errors as seen in the log above. The .generated file seems unable to be opened:
image

Try adding UENUM(BlueprintType) and uint8:

UENUM(BlueprintType)
enum class EUnitType : uint8
{
    :
}

1 Like

Thanks for your reply!
I changed the settings so I can edit the file.
I did the following, unfortunately with no succes:

Sorry, I should read the error report better. The name EUnitType already exists within Unit Conversions.

You could use namespaces or change the name of your enumeration. Try changing the name first since it may be the easiest move: EPhysicalUnitType

Thanks again for your time,
I refactored the enum as you suggested, unfortunately I got the same error:

Can you paste your enumeration as is so I can try it in my build. But I am building with 4.27 whereas it appears you are using UE5.0 :slight_smile:

/** Enumeration that specifies particular classes of unit */
enum class EPhysicalUnitType
{
	Distance, Angle, Speed, Temperature, Mass, Force, Frequency, DataSize, LuminousFlux, LuminousIntensity, Illuminance, Luminance, Time, PixelDensity, Multipliers,

	// Symbolic entry - do not use directly
	NumberOf,
};

That worked as is with 4.27:

I am going to try a prebuilt EA5.2 project. . . .

How do I add a C++ class in 5? . . . got it . . . under Tools

thank you for your efforts!

do you happen to know: do .generated files only excist after a successful compile?

The .generated are output from the Unreal Header Tool (UHT) and used by the Unreal Build Tool (UBT).

I am able to compile the enum with 5.0.0 but I had to add the UENUM() to it.

I did get to work using 5. I tried to show as much as I could:

1 Like

Thank you very much, I really appreciate the time you take to help me.
adding UENUM() did help a bit… I now have a new error, which seems really random, honestly :stuck_out_tongue:
just one error now:
image
I think I’ll reinstall ue5 and see if I can get it working

I resolved the issue by reinstalling the engine and using UENUM() as described by you. Thanks again. Best.

:slight_smile: :slight_smile: :slight_smile: