Basic build problem

I hate to bring this to the forum, but at the risk of clearly advertising my limited C++ experience, I’ve spent a day on this, and I’m sure its a trivial problem…
I’m trying to create a class that inherits AudioIODeviceCallback class.
I’ve simplified this down to the bone, but still can’t get rid of the compile-time error:

#include <juce_audio_basics/juce_audio_basics.h>
#include <juce_audio_devices/juce_audio_devices.h>
#include <juce_core/juce_core.h>
#include <juce_data_structures/juce_data_structures.h>
#include <juce_events/juce_events.h>
#include <juce_graphics/juce_graphics.h>
#include <juce_gui_basics/juce_gui_basics.h>

using namespace std;

class Acloc: public AudioIODeviceCallback
{
public:
};

The error is

In file included from …/…/Source/acloc.cpp:11:0:
…/…/Source/acloc.h:14:1: error: expected class-name before ‘{’ token
{

The only line in acloc.cpp is #include “acloc.h”.
Can someone explain?

Try this:

class Acloc : public juce::AudioIODeviceCallback
{
};

The juce header used to declare “using namespace juce” by default, but it doesn’t anymore, so you have to write juce::in front of juce class names.

1 Like

Ok, that did it.
I don’t see that in any of the examples, so I guess somewhere up above they must have had “using namespace juce;” that I didn’t notice…
Thanks very much.

@benvining,
Is there some reason why I shouldn’t just put “using namespace juce;” at the top of the header?

This post is a good summary:

In modern C++ you generally try to avoid putting global using namespace directives into headers (this also goes for using namespace std. Instead just qualify types with their namespace or narrow down the scope of using directives to e.g. function bodies or certain .cpp files.

The reason for this is that bypassing namespaces globally this way conflicts with the idea of namespaces which is to avoid symbol name clashes

1 Like

@daniel @PluginPenguin,
That makes sense…
Thanks,