Compiler error with Xcode 16.3 and JUCE 8.0.7

CMake based project with CXX_STANDARD set to 23

In file included from /path/to/project/_deps/juce-src/modules/juce_audio_basics/juce_audio_basics.mm:35:
In file included from /path/to/project/_deps/juce-src/modules/juce_audio_basics/juce_audio_basics.cpp:44:
In file included from /path/to/project/_deps/juce-src/modules/juce_audio_basics/juce_audio_basics.h:97:
/path/to/project/_deps/juce-src/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h:1208:45: error: no member named 'alignment_of_v' in namespace 'std'
 1208 |         auto requiredSampleAlignment = std::alignment_of_v<Type>;
      |                                        ~~~~~^
/path/to/project/_deps/juce-src/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h:1208:60: error: 'Type' does not refer to a value
 1208 |         auto requiredSampleAlignment = std::alignment_of_v<Type>;
      |                                                            ^
/path/to/project/_deps/juce-src/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h:44:20: note: declared here
   44 | template <typename Type>
      |                    ^
/path/to/project/_deps/juce-src/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h:1208:65: error: expected expression
 1208 |         auto requiredSampleAlignment = std::alignment_of_v<Type>;

The fix is to add #include <type_traits> to the top of modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h

While I’m at it might as well report that we’re also getting a bunch of warnings that we didn’t previously:

/path/to/project/_deps/juce-src/modules/juce_core/native/juce_ObjCHelpers_mac.h:346:73: warning: cast from 'signed char (*)(id, SEL)' to 'IMP' (aka 'id  _Nullable (*)(id _Nonnull, SEL _Nonnull, ...)') converts to incompatible function type [-Wcast-function-type-mismatch]
  346 |         [[maybe_unused]] const auto b = class_addMethod (cls, selector, (IMP) callbackFn, s.data());
      |                                                                         ^~~~~~~~~~~~~~~~
/path/to/project/_deps/juce-src/modules/juce_core/native/juce_ObjCHelpers_mac.h:340:52: note: in instantiation of function template specialization 'juce::ObjCClass<NSView>::addMethod<signed char>' requested here
  340 |     void addMethod (SEL selector, Fn callbackFn) { addMethod (selector, toFnPtr (callbackFn)); }
      |                                                    ^
In file included from /path/to/project/_deps/juce-src/modules/juce_audio_processors/juce_audio_processors.mm:35:
/path/to/project/_deps/juce-src/modules/juce_audio_processors/juce_audio_processors.cpp:175:13: note: in instantiation of function template specialization 'juce::ObjCClass<NSView>::addMethod<(lambda at /path/to/project/_deps/juce-src/modules/juce_audio_processors/juce_audio_processors.cpp:175:46)>' requested here
  175 |             addMethod (@selector (isOpaque), [] (id, SEL) { return YES; });
      |             ^
In file included from /path/to/project/_deps/juce-src/modules/juce_audio_processors/juce_audio_processors.mm:35:
In file included from /path/to/project/_deps/juce-src/modules/juce_audio_processors/juce_audio_processors.cpp:50:
In file included from /path/to/project/_deps/juce-src/modules/juce_audio_processors/juce_audio_processors.h:66:
In file included from /path/to/project/_deps/juce-src/modules/juce_gui_basics/juce_gui_basics.h:68:
In file included from /path/to/project/_deps/juce-src/modules/juce_graphics/juce_graphics.h:67:
In file included from /path/to/project/_deps/juce-src/modules/juce_core/juce_core.h:379:

Can you share more information about how you triggered these errors? I am unable to reproduce this with develop (or 8.0.7).

I’m issuing these commands in the JUCE repository.

cmake . -Bbuild -Werror=dev "-GNinja" -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DJUCE_BUILD_EXTRAS=ON -DJUCE_BUILD_EXAMPLES=ON "-DCMAKE_CXX_FLAGS=-Werror" "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13"
cmake --build build --parallel 14 --config Debug --target DemoRunner

There’s also something that looks suspicious. juce_AudioSampleBuffer.h is included in juce_audio_basics.h, which unconditionally includes juce_core.h, which unconditionally includes <type_traits> through juce_StandardHeader.h.

So type_traits should already be included, I don’t understand how that can be fixing the problem. Did you try to delete and regenerate the CMake project after updating Xcode?

Yes always working with clean generated builds.

We’re not using Ninja but -GXcode btw.

I’m working on a minimal example right now and will post it if and when I can isolate it out of our code base. My post was mainly just to help anyone else who was in this situation upgrading from 16.2 where it doesn’t happen to us.

After checking again I see I read the details slightly wrong out of our build logs.

It’s JUCE 8.0.3 that results in the compiler error with Xcode 16.3

JUCE 8.0.7 in fact works for us with 16.3

(repro of error with 8.0.3)

(8.0.7 without -Wno-cast-function-type-mismatch and -Wno-unused-but-set-variable)

Sorry for the confusion. I hope it’s still useful info for anyone stuck with the other combo.

Thanks!

1 Like

I still see the warning cast-function-type-mismatch on 8.0.7 in Xcode, but only if I build iOS simulator.

This is with Xcode 16.3.

Can also be reproduced in @phraemer repo GitHub - phraemer/juceissues: For exploring and reporting JUCE issues when building for iOS simulator. I used the ./generate_ios.sh in the root to generate a project. It is not listed as an error, but if you look in the build logs it is there.

1 Like

This should now be fixed on develop. Relevant thread here:

1 Like

Re-ran the jobs and all green now. Thanks!