Any chance of calling it 'juce_ADSR' instead of just 'ADSR'?


#1

Any chance of calling the class ‘juce_ADSR’ instead of just ‘ADSR’? in 5.4.2?
Thanks.


#2

Why not just use juce::ADSR?


#3

I don’t want to use Juce’s, it’s giving me a clash with my own ADSR class.
Or perhaps even jADSR ? like jassert or jlimit or jmin.


#4

add DONT_SET_USING_JUCE_NAMESPACE=1 to your Projucer project, then you just need to have the appropriate using juce::whatever declarations in your headers to avoid clashes.

Or namespace your own ADSR.


#5

Name collisions are the problem that namespaces are designed to solve. For some reason, everything in the JUCE namespace is automatically dumped into the global namespace in new projects.

To enable proper JUCE namespacing, in the Preprocessor Definitions of your Projucer project add the definition DONT_SET_USING_JUCE_NAMESPACE=1. You’ll then have to explicitly qualify the names of any JUCE symbols you use, but you’ll also avoid name collisions with your own code.


#6

Thanks for the answer. It’s just annoying and it seems a bit lazy for a Framework or API to use simple common names for it’s own classes.
For now, I’ve just changed Juce’s version name to jADSR, as it’s only used in one place.


#7

It’s just annoying and it seems a bit lazy for a Framework or API to use simple common names for it’s own classes.

That’s why namespaces exist


#8

So you don’t expect any framework to have an ASDR class?


#9

I expect a framework naming convention, like jassert, jlimit or jmin, jmax.
edit nevermind, I’ll do the DONT_SET_USING_JUCE_NAMESPACE=1 thing and see how it goes…thanks everyone.


#10

Tbh, those are the oddities here and probably used to either avoid clashing with keywords (like assert) or because people have a tendency to define their own min/max etc.
I think in an ideal world they wouldn’t have the j prefix.
More and more these days we’re using std::min, std::max etc. and no one is complaining about the std namespace.

You can probably just disambiguate yours with ::ADSR
But better to put your own in a namespace.


#12

Hmm, I might try my own namespace, that’ll be fun!


#13

I suspect that min and max may have prefixes so that they don’t get wrecked by the min/max macros that are defined in Windows.h if memory serves. Granted, there’s other ways around that problem but avoiding those names altogether is the simplest.


#14

Yeah, of course, it was just a bit of a shock that’s all. I suppose it teaches me to never update a framework when I’m halfway through a project!!! :smile: After all these years I never learn that, it seems.


#15

Yeah, some of those old juce names like jmin, jmax, jassert etc were done that way to work around the fact that system headers used to define macros for those symbols (ugh!).

But yes, if I was writing it all again in today’s climate, I wouldn’t use any prefixes.

I think a more valuable lesson would be “always follow the recommended best-practices for using namespaces”! :slight_smile:


#16

You guys are really good at not breaking everything, unlike those Unity bods!..