Experimental "build" jucer and namespaces


#1

Somewhat distinct from the recent thread involving what I call the “GUI” Jucer and namespaces, this involves the experimental jucer, the one that generates Makefiles/etc for various systems.

I have a systemic issue in my current project where having the jucer objects living in the global namespace causes me minor grief interacting with other things that I use (i.e., I do something reasonable and I get obscure compilation errors in some distant part of the code because of a name collision with Juce - it usually involves forward references, even if they aren’t in the root namespace…)

It seems as if there’s a way to avoid having the Juce elements in the global namespace when you amalgamate a Jucer - but I don’t see how to do this when using the experimental Jucer. Thoughts?


#2

For the “new” jucer I think I’ll certainly add an optional namespace…

For the old one, I think it’d be quite easy to achieve the same effect by editing the cpp/header template files to have a namespace declaration around them…?

Or more flexibly, you could edit the template files to have extra “user sections” at the start and end, in appropriate places so that you can manually add namespace declarations to the finished files.


#3

Urg, I feared that I wouldn’t get the issue across but :smiley: I managed to solve it while I was writing it up again!

This was entirely do to with the projects generated by the experimental Jucer. The issue was that each Juce class appears in two namespaces, ::juce and ::

For example, I can refer to juce::String or simply String and I’ll get the same results.

However, you can just set DON’T_SET_USING_JUCE_NAMESPACE in your .jucer project and all is fine. I didn’t think this would work because of juce_Config.h but it’s actually completely separate from that set of variables.