At the moment I use a “superheader” that I include instead of JuceHeader.h because windows.h (needed for juce_pluginHostType.h) has to be included before juce.h (in the superheader I only include windows.h and JuceHeader.h). Otherwise I get compilation errors depending of the order of compiling the source.
Maybe it might be useful to also have a post-Juce header section.
If this is a really bad idea and there is a better alternative to this (and the “superheader”) please tell me.
Surely the way to do this is just to have your own “super-header” file that includes JuceHeader.h ?
It’d be silly/wasteful/dangerous to add your own headers to JuceHeaders.h, because that file is used by other jucer-generated files, which certainly won’t benefit from having a load of random 3rd party code included while they get compiled.
I had a feeling that this might not be the best solution. I think I tried including windows.h where I thought it was needed (which is in quite a lot of places since I use juce_pluginHostType.h nested in classes, e.g. a class using an object from another class using an object from juce_pluginHostType.h, but had still problems while compiling and this way it seems to work.
Is there any better way than the latter done thoroughly?
Make your own header file. In it, include the juce headers, as you may see in the generated code. In old jucer generated code you can switch out the generated header for yours (it won’t be replaced). In any other .h files, include your header file.
In your header file, add files that all your code might need. You can also put externs to global variables if needed, and common definitions you may need. Once you’ve worked out the order once, you’re good to go.
component.cpp wil compile fine, but when compiling PluginEditor.cpp or PluginProcessor.cpp (or building the project) it will fail cause juce is included before windows.h.
Therefore I need something like this (maybe I could include component.h before the other headers but I don’t like that):
So instead of making my own header, I thought about the possibility to directly put this in the JuceHeader.h.
Though I think I will go for Bruce’s approach which has the advantage not having to mess with the jucer-generated header which I suppose is far better programming style.