Scripts for adding juce::

Anybody have any scripts or macros for adding juce:: in front of every type so I don’t need to do it manually?

Currently I’m using Xcode’s “fix all errors” which is doing an ok job, but sometimes it makes mistakes. And it only does one file at a time.

namespace juce?

oh man! this should be a Projucer tool!!!

I found an option inside Projucer’s project setting to auto define
using namespace juce;

The only time I’ve been manually using juce:: was with the juce::String

@aram the JUCE framework has moved to not using the using namespace juce method, as modern c++ encourages the proper use of namespaces. One can still choose to use that method, through the Projucer, but I assume the OP is looking to adopt the preferred method (as I am), and having a tool to automate the operation of adding the juce:: namespace in front of all of the JUCE apis, would be awesome! :slight_smile:


remove using namespace directive

(didn’t tried it myself)

I just kept building my project until I stopped getting errors. Didn’t take long, really. Don’t like to search&replace across the entire project, because I could have used a keyword/type/comment with the same text as some JUCE name. Plus, I’d need to know all possible JUCE symbols used in my project, anyway. It was just a lot easier to let the compiler tell me where I needed to add juce::.

Sorry, I wasn’t clear. I didn’t mean
using namespace juce
namespace juce
// your code

No no no no!

It’s really bad practice to just throw some of your own random symbols into somebody else’s namespace! That namespace doesn’t belong to you, and you don’t know what’s in there!

I can only think of one situation where you’d ever want to write namespace SomeBodyElsesCode {... which is when you need to declare an overridden handler function to let this other library deal with your own custom type (e.g. you sometimes need to add a hash handler to the std namespace in order to make std::hash work with your class), but when you do this, you need to treat it as a very dangerous operation, and only add the absolute bare minimum of symbols to their namespace.


Ug, I had to update 2000+ lines of code. Better to do it now than later I guess.

I am looking for the time in our schedule for this task…how long did that take? 2-4 hours?

I had about 32,000 lines of code that required 2000 changes. Probably took 4 hours or so.