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):
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!
asked Feb 12 '18 at 05:34 PM in C++ Programming
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 https://forums.unrealengine.com/development-discussion/engine-source-github/121146-how-to-compile-in-non-unity-mode?p=1047662#post1047662 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
answered Feb 13 '18 at 12:18 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here