[Solved] JUCE modules, includes and forward declarations

I've been having trouble getting a couple of modules to compile. This is my first time trying to create JUCE modules. One is dependent on the other. 

I started by simply copying files over from my project and putting them in folders, following instructions /examples for how to lay things out and create the juce_module_info json file.

After a fair bit of searching, trying, working through errors etc, I've honed it down to an issue of inheriting from a class in another module. Obviously this is done a lot in JUCE projects. Just not sure how to get it working in my context.

I have e.g:


class MyComponent.h // <-- this lives in another module

class SubMyComponent : public MyComponent

In the dependent module's juce_module_info:

// .. juce module includes
#include <modules/my_component/my_component.h

// .. module includes

I'm not sure if I need the class declaration there... without it I get 'Expected class name' for MyComponent, and with it I get 'Base class has incomplete type'

Obviously I cant include the header file directly as its already been included.

EDIT: I realised there was a "JuceHeader.h" include which was causing circular references.. removed that and it now all compiles nicely ! phew.. been a bit of a journey this one.


Headers inclusion sometimes leads to mess. You solved it. Congratulations :wink:

In my projects i always use one namespace by module and explicitly qualify juce namespace inside them. Probably a matter of taste.