What are the differences in c++ include behavior between iOS and Windows?

We’re having difficulties maintaining a working iOS build, because there are C++ compile errors that only manifest within an iOS compile chain.

It seems like there are differences in either the headers that are included, or in the effects of their inclusion between a Windows build and an iOS build of our project. I want to understand what causes these differences, and, more importantly, exactly what the differences are. So that we can hopefully come up with a strategy to avoid regularly causing iOS build problems when working in Windows.

As a micro example of the problem, I made a new blank project, and added a single new C++ Actor class. In the header for this class I added a public “FCollisionShape MyCollisionShape;” variable to its class definition. No other changes.

This compiles fine for Windows builds but does not compile if I try to make an iOS build (I am remote building on a Mac):

UATHelper: Packaging (iOS):     C:\Program Files\Epic Games\UE_4.18(18,2): error: unknown type name 'FCollisionShape'; did you mean 'ECollisionChannel'?
UATHelper: Packaging (iOS):   
UATHelper: Packaging (iOS):           FCollisionShape MyCollisionShape;
UATHelper: Packaging (iOS):   
UATHelper: Packaging (iOS):           ^~~~~~~~~~~~~~~

Now, this example is easy enough to resolve by explicitly including WorldCollision.h, but after our team has worked exclusively on Windows for a few days we can easily have a large number of related errors, because they didn’t show up in general development.

What I really want to understand is what the exact difference in include behavior is between the two platforms, and ideally, why this difference exists. If you are able to go further, and make suggestions on how we might avoid this flavor of platform specific compile errors in the future, we would be keen to hear them!

Cheers,

Jonathan

Okay, thankfully a colleague was able to put me on the right track.

It turns out the difference is “unity build”, which is enabled by default in Windows builds, and (presumably) disabled by default in (at least) remote iOS builds.

Unity build is a ‘clever’ trick that concatenates multiple .cpp files into one before compilation, in order to speed up compilation times. I say ‘clever’ because it can/does hide legitimate code bugs like my questions example.

To bring the two builds inline (which I consider a must, even if at the expense of a slower compile) you need to disable unity build. See How to compile in non-unity mode? - #3 by huwp - Engine Source & GitHub - Unreal Engine Forums for an explanation on how to do that.

fwiw, I strongly believe features like unity build, which give a speedup at the expense of ‘accurate’ compilation should be default-off