I came across an error when compiling the JUCE (6.0.5) examples:
The two function calls to CallOutBox::launchAsynchronously()
in PushNotificationsDemo.h
produce the following error:
no viable conversion from 'juce::ColourSelector *' to 'std::unique_ptr<Component>'
The first parameter passed to the function – the one that causes the error – is a raw pointer to a new ColourSelector object, and clang
expects an explicit conversion to a unique pointer. If I wrap the pointer in either of the lines in a unique_ptr
constructor, then everything works just fine:
// compiler error:
CallOutBox::launchAsynchronously(paramControls.accentColourSelector, paramControls.accentColourButton.getScreenBounds(), nullptr);
// no error:
CallOutBox::launchAsynchronously(std::unique_ptr<juce::Component>(paramControls.accentColourSelector), paramControls.accentColourButton.getScreenBounds(), nullptr);
I’ve gotten it to work now, but I’m posting this to see if anyone can help me clear up the issue of why the unmodified example doesn’t work?
I’m not that experienced with C++ but it seems that implicit conversion should not be a problem? (And, of course, it can’t be if the example works just fine for everyone else.) I’m using the standard XCode version of clang
(12.0.0) – haven’t gotten it to work with gcc
at all so far so can’t comment on whether it’s just a compiler issue.
Any insights appreciated.
EDIT: formatting