Is there any such thing as a "library" data class?

I use a lot of structs to encapsulate custom data types I need for my project, and I’m running into an increasingly common problem where I need Class A to have an include for Class B not because it needs any of B’s functionality, but purely because B’s header has the definition for some struct or enum that A needs to function. It’s getting increasingly hard to avoid circular dependency, which I know is a sign of bad design, so this got me curious- most of unreal’s classes derive from UObject in some way, but is there any such thing as a pure data class that I could use to store my libraries, so everyone can refer to a single common source instead of coupling to each other?

Try looking up the PreCompiledHeader, or PCH for short. You might be able to use that.

Hmm okay… I also realized it might work to just make a class derived from UObject (so I get ustruct()s), and never give that class includes to anything.

Also, I am pretty certain that with recent engine versions there is no requirement to have a UClass in a header file anymore, so try creating a regular .h file(remember to #include your project header file) and putting a UStruct in there. It should compile fine. I hope.

I haven’t tried this since… 4.7, I think, so it probably works now, but I was scared away from doing that by an earlier project version where I made an empty class, added some data, and compiled it, only for it to completely disappear from my project. UE would protest when I tried making a new class with the same name, so I knew the system could see it, but I couldn’t edit it or access/include its member functions, so I ended up having to delete it from the source folder, delete my binaries, clean & build my codebase, then generate new project files from ue.

For that sort of thing, I find deleting the Intermediate folder, right clicking your project and pressing ‘Generate Visual Studio Files(/Solution/Whatever)’, then rebuilding the project works. The build process automatically takes care of cleaning the binaries. Oh, and I definitely recommend source control.

Hope you get this all worked out.

Awesome, I’ll try that next time I have a hiccup- thanks for the suggestion :slight_smile: