Download

How to remove a deprecated Header without causing compiler errors in generated code?

Hi there,

the question is as stated in the topic…you have an old, deprecated Headerfile you want to remove from the codebase, how could you do it without breaking the project? I’ve spend a couple hours on trial and error as well as research on the Answer Hub, but I still can’t kill the header without causing a compiler meltdown.

Here is what I did:

  • removed the Header in VS (worked but the header is still in the codebase)
  • deleted the Header in explorer -> compiler error
  • deleted Header and the generated Header (Explorer) -> compiler Error
  • deleted the content in the binary and/ or Intermediate and/ or saved folder -> can’t even load the code in VS anymore

Is there a clean way to get rid of outdated headers without breaking links in the Unreal Header Tool?

Thanks in advance for any hint that can help me to remove this header WITHOUT making a clean project and copy/ paste the Content and Source Folder? It would require quite some work to set up everything correctly again since the game is pretty big.

Remove the header file manually, then right click on your .uproject file -> Generate Visual Studio project files.

That should work fine as far as I know.

Thanks TS100101,

unfortunally the compilier error is still persistent. Looking on the error message it looks that it should be related to admin rights or something like that…however I run Visual Studio as Admin and the compiler error is gone as soon as I restore the deleted header from the trashbin.

e046330e4333b2f4af3b5074499f793d4e5e8aea.jpeg

Remove file.
Remove #include directive to file.
Generate project.
Then do full rebuild of the solution. (From solution menu - rebuild solution).

Also your screenshot does not show actual error. The error is printed into “output” window.

Thanks, now it worked.

Embarrassing, there really was a include left in a class I wasn’t aware of since it was never actually used so far.

So was it the rebuild or just a leftover?

When I tried to rebuild the solution in Visual Studio it got the compiler error once the header was removed from disc because it was still referenced in the includes of another class. With removing the preprocessor (the leftover) it worked fine after generating the project files.

I guess it can be said it was the leftover…which was the embarrassing part :slight_smile: