Qeustion about class name length limitation when adding code through the editor

Hi,

as the title says I have a few questions about the limitation when adding code through the editor. This happens when you choose the “Add New -> New C++ Class” option in the content browser. After selecting the parent class and entering a class name with more than 32 characters you will see the error: “The class name must not be longer than 32 characters.”

Now I’m wondering why is there such a limitation? (Windows max file path length maybe?)
Does the U/F/I prefix count towards this limit?
Will I run into problems when I manually add classes with longer names to existing/manually created cpp/h files?

It seems somewhat counter-intuitive to me that on the one hand coding standards demand descriptive names for everything but on the other hand limiting the length of class names may result in “creative” names or abbreviations.

I’m thankful for any insights.

Edit:
Does the U/F/I prefix count towards this limit? Looks like the answer is no.

2 Likes

Bump. I’m also curious about this. I am trying to keep my class names succinct, but I often find that they get close to, or exceed the character limit. What are the consequences of this ?

Hello,

One of the main reasons for limiting the class name length is, as you mentioned, to control the max length of the file path. With nested folders, the length of the filename could become an issue if it is deeply nested with an overly long/complex name. While descriptive names are recommended, if you find that the character limit becomes an issue you can also add comments at the top of the .cpp/.h file to give a description of what task the class is meant to do.

Cheers

Okay cool, thank you very much for the (delayed) answer (but better than no answer what so ever so thank you again) :slight_smile:

If it really is only a concern of the file name/path length then I am still able to give my classes, structs etc. the actual descriptive name I want. In that case I can live with it. Although an second optional field with the actual name of the class inside the created .h/.cpp files would be nice. So the first one would be limited to 32 characters used as both the file name and the class name. And the second one would be the “override” for the class name inside the .h/.cpp file.

If this is a thing anyone (besides myself) would be interested in I may take a look when I find the time and create a custom branch + pull request (if that’s something Epic would consider?) for it.

I still care about increasing the name length limitation :slight_smile:
Combined with lack of namespace support this is a real problem.

Wonder why this is an issue.

i did it by renaming the class after i create it from unreal engine
j - close unreal engine
2 - rename the class to what ever you want
3- rename file to match class name but without U or A
4- regernate visual studio files from right click on your project and choose generate visual studio project files

but honestly i am shorten the name because its bad practice to make the name exceed 32 characters