JUCE doesn't build on Windows using Clang (VS2022)

I’m getting the following errors:

Build started...
1>------ Build started: Project: Vanguard_SharedCode, Configuration: Release x64 ------
1>In file included from ..\..\JuceLibraryCode\include_juce_gui_basics.cpp:8:
1>In file included from ..\..\modules\JUCE\modules\juce_gui_basics/juce_gui_basics.cpp:46:
1>In file included from ..\..\modules\JUCE\modules\juce_gui_basics/juce_gui_basics.h:57:
1>In file included from ..\..\modules\JUCE\modules\juce_graphics/juce_graphics.h:58:
1>In file included from ..\..\modules\JUCE\modules\juce_core/juce_core.h:204:
1>In file included from ..\..\modules\JUCE\modules\juce_core/system/juce_StandardHeader.h:46:
1>In file included from C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\algorithm:11:
1>In file included from C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\xmemory:16:
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\xutility(1697,19): error : no matching constructor for initialization of 'juce::CharPointer_UTF8'
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\xutility(1543,18): message : in instantiation of default member initializer 'std::reverse_iterator<juce::CharPointer_UTF8>::current' requested here
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\concepts(100,8): message : in evaluation of exception specification for 'std::reverse_iterator<juce::CharPointer_UTF8>::reverse_iterator' needed here
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\concepts(100,8): message : while substituting template arguments into constraint expression here
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\concepts(103,33): message : while checking the satisfaction of concept 'constructible_from<std::reverse_iterator<juce::CharPointer_UTF8>>' requested here
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\concepts(103,33): message : while substituting template arguments into constraint expression here
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\concepts(243,40): message : (skipping 16 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\xutility(5189,64): message : in instantiation of variable template specialization 'std::_Memchr_in_find_is_safe<std::reverse_iterator<juce::CharPointer_UTF8>, unsigned int>' requested here
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\xutility(5198,31): message : in instantiation of function template specialization 'std::_Find_unchecked<std::reverse_iterator<juce::CharPointer_UTF8>, unsigned int>' requested here
1>..\..\modules\JUCE\modules\juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h(164,72): message : in instantiation of function template specialization 'std::find<std::reverse_iterator<juce::CharPointer_UTF8>, unsigned int>' requested here
1>..\..\modules\JUCE\modules\juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h(178,42): message : in instantiation of function template specialization 'juce::AccessibilityTextHelpers::findNextLineOffset(juce::CharPointer_UTF8, juce::CharPointer_UTF8, juce::CharPointer_UTF8, juce::AccessibilityTextHelpers::Direction, juce::AccessibilityTextHelpers::IncludeThisBoundary)::(anonymous class)::operator()<std::reverse_iterator<juce::CharPointer_UTF8>, std::reverse_iterator<juce::CharPointer_UTF8>>' requested here
1>..\..\modules\JUCE\modules\juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h(228,41): message : in instantiation of function template specialization 'juce::AccessibilityTextHelpers::findNextLineOffset<juce::CharPointer_UTF8>' requested here
1>..\..\modules\JUCE\modules\juce_core/text/juce_CharPointer_UTF8.h(39,14): message : candidate constructor not viable: requires single argument 'rawPointer', but no arguments were provided
1>..\..\modules\JUCE\modules\juce_core/text/juce_CharPointer_UTF8.h(44,5): message : candidate constructor not viable: requires single argument 'other', but no arguments were provided
1>Done building project "Vanguard_SharedCode.vcxproj" -- FAILED.
2>------ Build started: Project: Vanguard_VST3, Configuration: Release x64 ------
2>include_juce_audio_plugin_client_VST3.cpp
2>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\numeric(32,1): error C2220: the following warning is treated as an error
2>C:\dev\Vanguard\modules\JUCE\modules\juce_audio_plugin_client\VST3\juce_VST3_Wrapper.cpp(3020): message : see reference to function template instantiation '_Ty std::accumulate<ElementType*,short,juce::JuceVST3Component::activateBus::<lambda_1>::()::<lambda_1>::()::<lambda_1>>(const _InIt,const _InIt,_Ty,_Fn)' being compiled
2>        with
2>        [
2>            _Ty=short,
2>            ElementType=juce::AudioChannelSet,
2>            _InIt=juce::AudioChannelSet *,
2>            _Fn=juce::JuceVST3Component::activateBus::<lambda_1>::()::<lambda_1>::()::<lambda_1>
2>        ]
2>C:\dev\Vanguard\modules\JUCE\modules\juce_audio_plugin_client\VST3\juce_VST3_Wrapper.cpp(3020): message : see reference to function template instantiation '_Ty juce::JuceVST3Component::activateBus::<lambda_1>::()::<lambda_1>::operator ()<juce::Array<juce::AudioChannelSet,juce::DummyCriticalSection,0>>(_T1 &) const' being compiled
2>        with
2>        [
2>            _Ty=short,
2>            _T1=juce::Array<juce::AudioChannelSet,juce::DummyCriticalSection,0>
2>        ]
2>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103\include\numeric(32,1): warning C4242: '=': conversion from 'int' to '_Ty', possible loss of data
2>        with
2>        [
2>            _Ty=short
2>        ]
2>Done building project "Vanguard_VST3.vcxproj" -- FAILED.
3>------ Build started: Project: GeneratePayloads, Configuration: Release x64 ------
3>        1 file(s) copied.
3>INFO   : *** BUILD SCRIPT ***
========== Build: 1 succeeded, 2 failed, 3 up-to-date, 0 skipped ==========

It started with this commit here:

Same as Compilation fails at juce_AccessibilityTextHelpers.h. The CharPointer classes need to be default constructible to be used as bidirectional (and even forward) iterators in C++20.

2 Likes

That often means your class has no default (or appropriate) constructor, which juce::CharPointer_UTF8 does not, per the documentation: https://docs.juce.com/master/classCharPointer__UTF8.html

This seems suggested here, as well:
message : while checking the satisfaction of concept 'constructible_from<std::reverse_iterator<juce::CharPointer_UTF8>>' requested here

In this case, it is not because there is specifically no default constructor, but instead, it seems the wrong type of Iterator is being used in the construction of the reverse_iterator.

The problem seems to be the incorrect template class for reverse_iterator, although I am not 100% about JUCE’s class, I imagine it doesn’t fit the qualifications mentioned in the C++ documentation: std::reverse_iterator is an iterator adaptor that reverses the direction of a given iterator, which must be at least a LegacyBidirectionalIterator or model bidirectional_iterator (since C++20). So it would have to be one of those two types of Iterators to use reverse_iterator on it. You could write a custom iterator class.

This is already fixed in develop.

1 Like

And in 7.0.1 master as well.

1 Like