Plugin Code Updating to 4.15

We have a C++ plugin that should be migrated to Unreal 4.15 but so far we have not managed to find out how to do it in backwards compatible manner.

The main problem however is that we want to use one codebase and migrate to UE 4.15 and still be backwards compatible with older versions (UE version <= 4.14). The new rule that all cpp files should start with their own header and not with the precompiled one directly contradicts the pre 4.15 rule of one precompiled header at the beginning of every cpp.

Reading in the forum I have found this question Precompiled header includes break in 4.15 and as suggested inside I’ve tried this option inside Build.cs file:

PCHUsage = PCHUsageMode.NoSharedPCHs;

but as far as I can see this is not making the plugin build like the old system, not to mention that there are compilation errors. I have tried another thing - setting the precompiled header that we should use with

PCHHeaderField = “Private/MyPluginPrivatePCH.h”;

and this seems to work as advertised - Unreal includes that precompiled header and things are fine as long as every cpp still starts with it’s corresponding header.

Unfortunately this is not backwards compatible because of the contradicting build header rules… unless we include some pre-build step that comments/uncomments the precompiled header in every cpp but this is extra work that we prefer not doing, not to mention that I see no way of doing this in platform agnostic way.

Any suggestions on how to update our code and retain backwards compatibility?

Hi, I am struggling with updating plugins also. When I try your fix, i get:

Error	CS0103	The name 'PCHHeaderField' does not exist in the current context	

Did this work for you? Thanks!

PCHHeaderField = "Private/MyPluginPrivatePCH.h";

is going to work only for UE4.15 as PCHHeaderField is UE4.15 specific and I am not sure it changes anything as it still enforces the 4.15 default behavior of UE setting your precompiled headers for you (meaning your code should not include them), but at least you know that the correct precompiled header is set instead of deduced from some rule.

This is not giving us backwards compatibility as I mentioned, but if you wish to go through this path, for pre UE4.15 you should not use PCHHeaderField and you can’t even have it in some if that is not executed for pre UE4.15, the only solution for that is to use C# reflection, something like this (not accurate and written from memory, but could be some starting point) :

var PCHHeader = this.GetType().GetField(“PCHHeaderField”);

if(PCHHeader != null)

{

PCHHeader.SetValue(…);

}

Wish you luck, Nikolay

hello everyone,
I would like to ask your assistance pertains on how to install your plugins in ue 4.15. Anybody out there who wants to give me the procedure? Please help.