How explicit the order in JuceHeader

After imported my modules in a juce project, in JuceHeader.h I have this:

#include <ayra_audio_processors_engine/ayra_audio_processors_engine.h>
#include <ayra_gui/ayra_gui.h>
#include <ayra_pdf/ayra_pdf.h>

but the correct order of modules should be this one:

#include <ayra_gui/ayra_gui.h>
#include <ayra_pdf/ayra_pdf.h>
#include <ayra_audio_processors_engine/ayra_audio_processors_engine.h>

There’s a way to specify this and not doing it each time I open Xcode from Projucer?

here the header defined of my modules:

ayra_gui.h

#pragma once
#define AYRA_GUI_H_INCLUDED

#include <ayra_selection_engine/ayra_selection_engine.h>
#include <juce_gui_extra/juce_gui_extra.h>

using namespace juce;

#include "continuous_scrollbar/ContinuousScrollBar.h"
#include "continuous_scrollbar/continuous_scrollbar_template/ContinuousScrollBarModel1.h"

#include "draggable_component/DraggableComponent.h"

#include "scroll_component/ScrollComponent.h"

#include "grid_component/GridComponent.h"
#include "grid_component/grid_models_template/GenericGridModel1.h"
#include "grid_component/grid_models_template/GenericGridModel2.h"
#include "grid_component/grid_models_template/GenericGridModel3.h"

#include "selector_component/SelectorComponent.h"

#include "enter_text_dialog_window/EnterTextDialogWindow.h"

#include "popup_nemu_quick_search/PopupMenuQuickSearch.h"

ayra_pdf.h


#pragma once
#define JUCE_AYRA_PDF_H_INCLUDED

#include <juce_gui_extra/juce_gui_extra.h>

#include "pdf_component/PdfComponent.h"

ayra_audio_processors_engine.h

#pragma once
#define JUCE_AYRA_PROCESSORS_EINGINE_H_INCLUDED

#include <juce_audio_utils/juce_audio_utils.h>
#include <juce_audio_processors/juce_audio_processors.h>
#include <juce_audio_devices/juce_audio_devices.h>
#include <juce_dsp/juce_dsp.h>
#include <ayra_gui/ayra_gui.h>
#include <ayra_pdf/ayra_pdf.h>

using namespace juce;

#include <semaphore>

#include "audio_utils/ayra_RingBuffer.h"

#include "gui_utils/ayra_Commons.h"
#include "gui_utils/ayra_ToggleableTextButton.h"
#include "gui_utils/ayra_KeyboardComponent.h"
#include "gui_utils/ayra_ExternalAudioDeviceSelectorComponent.h"

//==============================================================================

#include "ayra_internal_plugins/internal_processor_base_classes/ayra_InternalAudioProcessor.h"
#include "ayra_internal_plugins/internal_processor_base_classes/ayra_InternalAudioProcessorEditor.h"
#include "ayra_internal_plugins/ayra_InternalPlugins.h"

// midi_fx

#include "ayra_internal_plugins/midi_fx/ayra_MidiHelpers.h"

#include "ayra_internal_plugins/midi_fx/ayra_midi_io/ayra_MidiIOs.h"

#include "ayra_internal_plugins/midi_fx/ayra_midi_filters/ayra_MidiTypeFilter.h"
#include "ayra_internal_plugins/midi_fx/ayra_midi_filters/ayra_MidiChannelFilter.h"
#include "ayra_internal_plugins/midi_fx/ayra_midi_filters/ayra_MidiValueFilter.h"

#include "ayra_internal_plugins/midi_fx/ayra_midi_transposers/ayra_MidiChannelTransposer.h"
#include "ayra_internal_plugins/midi_fx/ayra_midi_transposers/ayra_MidiTransposer.h"

#include "ayra_internal_plugins/midi_fx/ayra_midi_type_remapper/ayra_MidiTypeRemapper.h"

// audio_fx

#include "ayra_internal_plugins/audio_fx/ayra_audio_io/ayra_ExternalAudioIOs.h"

#include "ayra_internal_plugins/audio_fx/ayra_connector/ayra_Connector.h"
#include "ayra_internal_plugins/audio_fx/ayra_panpot/ayra_Panpot.h"
#include "ayra_internal_plugins/audio_fx/ayra_gain/ayra_Gain.h"
#include "ayra_internal_plugins/audio_fx/ayra_SineWaveSynth.h"
#include "ayra_internal_plugins/audio_fx/ayra_latency/ayra_Latency.h"

//==============================================================================

// pdf_viewer

#include "ayra_internal_plugins/pdf_viewer/ayra_PdfViewer.h"

// replacer

#include "ayra_internal_plugins/replacer/ayra_Replacer.h"

// hard_worker

#include "ayra_internal_plugins/hard_worker/HardWorkerProcessor.h"

You should make your headers order independent between each other. If your header needs another one, it should include it explicitly.

So for example if your #include <ayra_pdf/ayra_pdf.h> requires #include <ayra_gui/ayra_gui.h> it should include it and not assuming someone else will include it before.

2 Likes

but ayra_audio_processors_engine.h includes

#include <ayra_gui/ayra_gui.h>
#include <ayra_pdf/ayra_pdf.h>

doesn’t it enough?

but ayra_pdf.h doesn’t include ayra_gui.h

1 Like

Thank you… But I don’t understand why… ayra_pdf.h doesn’t need ayra_gui.h… only ayra_audio_processors_engine.h needs both…

Idk, you said that the order should be this:

#include <ayra_gui/ayra_gui.h>
#include <ayra_pdf/ayra_pdf.h>

Maybe you have a circular include dependency, or your dependencies are not set correctly in the modules metadata ?

After reading the thread it is unclear what the issue is. You do not specify WHY the order is wrong. What is the actual issue you are seeing.

Also, probably not important, but, you should not really be doing using namespace juce;, it is not ‘best practice’. and since you are using #pragma once, what is the reason for the old style #define AYRA_GUI_H_INCLUDED include guard define?