DSP Module method name collision with global macro

I am finally trying the dsp module for real but am running into a method naming collision with a globally defined macro called check().
In juce_FIRFilter and juice_IIRFilter there are methods called check() and due to including <Cocoa/Cocoa.h> in another spot, my project includes AssertMacros.h from the Mac OS X SDK 10.12 which contains

#ifndef check
#define check(assertion)  __Check(assertion)

This leads to build errors “Expected member name…” because the macro gets replaced.
Has anyone else seen this? Is there an easy fix? IMHO check() is a terrible method name and should be changed (maybe to checkCoefficients()?) and that would solve the issue.

I agree, check() is a little ambiguous. Personally I think validate() or validateCoefficients() would be a better name for this method.

As a solution, does it help to include the Cocoa.h after the Juce includes? If it still complains, you can add an #undef check between the juce headers and the cocoa includes maybe?

#defines in general are annoying for exactly that reasons, so I agree, to generic names should be avoided

What is terrible is that some OS X headers define macros without caring about polluting everybody’s code. Fortunately there is a way to prevent that: add __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0 to the preprocessor defines (or add a #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 before including the Cocoa header).

From the AssertMacros.h header:

1 Like



1 Like