# User header section in JuceHeader.h

**URL:** <https://forum.juce.com/t/user-header-section-in-juceheader-h/5830>\
**Category:** The Projucer\
**Created:** [November 1, 2010, 3:11pm UTC](https://forum.juce.com/t/user-header-section-in-juceheader-h/5830 "2010-11-01T15:11:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ckk](https://avatars.discourse-cdn.com/v4/letter/c/d26b3c/32.png) [@ckk](https://forum.juce.com/u/ckk)\
**Post date:** [November 1, 2010, 3:11pm UTC](https://forum.juce.com/t/user-header-section-in-juceheader-h/5830/1 "2010-11-01T15:11:14Z")

</div>

Hi Jules,

could you include a user header section in JuceHeader.h that won’t be changed when rerunning the Jucer, e.g. something like:

```auto
//[Userheaders]
//[/Userheaders]

#include "AppConfig.h"
#include "juce_amalgamated.h"

namespace ProjectInfo
[...]
```

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.

Chris

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 1, 2010, 3:21pm UTC](https://forum.juce.com/t/user-header-section-in-juceheader-h/5830/2 "2010-11-01T15:21:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ckk](https://avatars.discourse-cdn.com/v4/letter/c/d26b3c/32.png) [@ckk](https://forum.juce.com/u/ckk)\
**Post date:** [November 2, 2010, 10:56am UTC](https://forum.juce.com/t/user-header-section-in-juceheader-h/5830/3 "2010-11-02T10:56:24Z")

</div>

> [@jules](#):
>
> Surely the way to do this is just to have your own “super-header” file that includes JuceHeader.h ?

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?

Thanks,  
Chris

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 2, 2010, 12:07pm UTC](https://forum.juce.com/t/user-header-section-in-juceheader-h/5830/4 "2010-11-02T12:07:41Z")

</div>

Sorry, I don’t understand the problem…

---

<div class="post-metadata">

**Author:** ![Bruce\_Wheaton](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@Bruce\_Wheaton](https://forum.juce.com/u/Bruce_Wheaton)\
**Post date:** [November 2, 2010, 11:30pm UTC](https://forum.juce.com/t/user-header-section-in-juceheader-h/5830/5 "2010-11-02T23:30:01Z")

</div>

Chris,

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.

Bruce

---

<div class="post-metadata">

**Author:** ![ckk](https://avatars.discourse-cdn.com/v4/letter/c/d26b3c/32.png) [@ckk](https://forum.juce.com/u/ckk)\
**Post date:** [November 3, 2010, 10:20am UTC](https://forum.juce.com/t/user-header-section-in-juceheader-h/5830/6 "2010-11-03T10:20:32Z")

</div>

Hi Bruce,

so you have an extra header that you include above JuceHeader.h? This seems to be a much cleaner approach than what I do.

@jules:  
I use a component that needs windows.h which has to be included before juce. The component is then used in PluginEditor.

```auto
component.h:
  #include "windows.h"
  #include "juce.h"

PluginEditor.h:
  #include "../JuceLibraryCode/JuceHeader.h"
  #include "../JuceLibraryCode/JucePluginCharacteristics.h"
  #include "PluginProcessor.h"
  #include "component.h"

PluginProcessor.h:
  #include "../JuceLibraryCode/JuceHeader.h"
  #include "../JuceLibraryCode/JucePluginCharacteristics.h"
```

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):

```auto
component.h:
  #include "windows.h"
  #include "juce.h" 

PluginEditor.h:
  #include "windows.h"
  #include "../JuceLibraryCode/JuceHeader.h"
  #include "../JuceLibraryCode/JucePluginCharacteristics.h"
  #include "PluginProcessor.h"
  #include "component.h"

PluginProcessor.h:
  #include "windows.h"
  #include "../JuceLibraryCode/JuceHeader.h"
  #include "../JuceLibraryCode/JucePluginCharacteristics.h"
```

And since this are all appearences off JuceHeader.h I simply made a SuperHeader.h that I include instead of JuceHeader:

```auto
SuperHeader.h:
  #include "windows.h"
  #include "../JuceLibraryCode/JuceHeader.h"
```

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. 🙂

Chris

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 3, 2010, 10:47am UTC](https://forum.juce.com/t/user-header-section-in-juceheader-h/5830/7 "2010-11-03T10:47:28Z")

</div>

That’s what I was trying to suggest earlier, but I guess I didn’t make myself very clear!

---

<div class="post-metadata">

**Author:** ![Bruce\_Wheaton](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@Bruce\_Wheaton](https://forum.juce.com/u/Bruce_Wheaton)\
**Post date:** [November 3, 2010, 1:32pm UTC](https://forum.juce.com/t/user-header-section-in-juceheader-h/5830/8 "2010-11-03T13:32:12Z")

</div>

I was translating for you Jules!
