C++20

Hi JUCE devs!

Have you any timescale for adding support for using JUCE with C++20?

I just gave it a go with Xcode 13, and found that JUCE doesn’t compile (at least, on macOS - didn’t try with Android / Windows).

It’d be a lovely thing :slight_smile:

Best wishes,

Pete

What errors are you seeing? I have C++20 set as my language standard and Juce compiles just fine

I’ve only disabled char8_t, which doesn’t work with CharPointer_UTF8 constructors. Everything else seems to be fine.

Hi @benvining errors compiling on macOS?

e.g. compiling this code in the JUCE library:

        CFObjectHolder<CFStringRef> contextName { properties.name.toCFString() };

@kamedin how do you disable char8_t …?! :slight_smile:

Thanks folks,

Pete

...modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm:1335:41:
No matching constructor for initialization of 'CFObjectHolder<CFStringRef>'
(aka 'CFObjectHolder<const __CFString *>')

in file included from

...modules/juce_audio_processors/juce_audio_processors.cpp:198:

Did you try compiling in Xcode 13 without C++20? It might be an Xcode 13 issue rather than a C++20 issue, or a combination of both.

With a compiler option. In GCC and Clang, -fno-char8_t. In MSVC, /Zc:char8_t-. Doesn’t seem like the CFObjectHolder issue has to do with C++20, but I’m not on Mac to check it.

Hi @kamedin thank you very much, that flag was a great tip!

@ed95 this was my fix for the juce_AudioUnitPluginFormat.mm file …:

-            CFObjectHolder<CFStringRef> contextName { properties.name.toCFString() };
+          CFObjectHolder<CFStringRef> contextName;
+          contextName.object = properties.name.toCFString();


-        CFObjectHolder<CFPropertyListRef> propertyList { CFPropertyListCreateFromStream (kCFAllocatorDefault, stream.get(), 0,
-                                                                                         kCFPropertyListImmutable, &format, nullptr) };
+        CFObjectHolder<CFPropertyListRef> propertyList;
+        propertyList.object = CFPropertyListCreateFromStream (kCFAllocatorDefault, stream.get(), 0,
+           kCFPropertyListImmutable, &format, nullptr);

Hoping this helps!

Pete

i filed this bug a few weeks back.

2 Likes

This has been fixed on the develop branch here:

We’ve also added support to the Projucer for setting the project language standard to C++20:

2 Likes

Thanks @ed95 !

Pete