Download

Why does unreal have so much code in headers ?

So, why does unreal have so much code in headers ? In some parts I understand because it’s either inlined code or templates (though I doubt the efficiency of inline when your executable is 100MB ) but in others I don’t get it at all.
My point is that this slows compilation down a lot and with a build taking up to 2 hours, I don’t see why it is this way.

I don’t remember longer codes to be in headers, you could copy a few examples so we’ll know what you mean.

I don’t see how “small code” is an excuse for this. If you make modifications to that particular function, you’re going to wait around an hour for each modification instead of like a minute if it was in a .cpp. How is that an excuse ?

Just to name a few I’ve been looking at lately : FDynamicPassMeshDrawListContext::FinalizeCommand, 14 lines
FDecalRenderingCommon::ComputeFinalDecalBlendMode, 40 lines
FMeshDrawShaderBindingsLayouts::GetDataSizeBytes, 15 lines (most if not all functions in MeshDrawShaderBindings.h are written in .h )
FShaderUniformBufferParameter FShader::GetUniformBufferParameter, 24 lines
FShader::SerializeInline ( it says inline, but it’s not inlined), 124 lines