I have an issue with code spontaneously no longer building. My changes have been relatively minor, but I’m getting a completely unhelpful error message that just says ‘Failed to Generate Code’. I’m unsure how to progress.
Thanks!
Edit: It looks like none of the generated headers are being generated by the UHT. There’s nothing in the output logs indicating any failure except ‘Failed to generate code’ and ‘UnrealHeaderTool failed for target’. These error messages are painfully vague.
Preprocessor directives such as an #if directive are presently to be avoided.
Circular dependencies can cause the UHT to fail and generate the above error.
You can’t use the “Compile” button inside Rocket if you change any of the headers. You can change the code in the .cpp files and that’s fine - but it apparently skips the pre-processed header build step. Maybe that’s your issue?
I could, but I have an idea of what the issue is and am able to get building again. It would seem I had a circular dependency that wasn’t immediately obvious, and that the UHT has trouble with said circular dependency - it would be nice for it to throw a specific error when this is the case to make it easier to find; I resorted to commenting out the majority of my code base and putting it back in piece by piece.
I was additionally using an #if directive, and I’m not sure that the UHT can handle that either. I’m assuming it does not do any form of pre-processing at present?
That is correct. There is limited preprocessing in that UHT understands the CPP macro and NULL, and follows #include dependencies, but that’s about it really. It certainly won’t like your #if.
It’s certainly a much-requested feature and thus is on our list of things to look at, but it is non-trivial due to the current build model. At the moment, UHT treats each header individually and has no notion of what the compiler ends up seeing.
So, for example, you may have a macro 3 levels deep in a PCH file, which is included by every .cpp, which it includes before your header. The compiler then ‘sees’ the define when it parses your header. UHT isn’t involved in any of that process. If it had to repeat a full PCH pass beforehand, it would seriously cripple builds speeds and programmer workflow.
In short, it’s not something we can just ‘turn on’… there’s a lot to be considered and other things need to happen before it can be attempted. But it is something we want to do.
already solved it myself. I just missed reading the comment about to make sure to have installed the June 2010 DirectX runtime. Once done, everything compiled perfectly.