From c7c26fa9f033c196c48e743deb6ae16e524ff29a Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Tue, 17 Apr 2018 18:46:55 +0100 Subject: [PATCH] Removed the OS X 10.5 and 10.6 deployment target options from the Projucer and enabled more C++11 features across all platforms --- BREAKING-CHANGES.txt | 25 +- .../DemoRunner.xcodeproj/project.pbxproj | 2 + .../iOS/DemoRunner.xcodeproj/project.pbxproj | 2 + .../DemoRunner/Source/Demos/DemoPIPs1.cpp | 10 +- .../DemoRunner/Source/Demos/DemoPIPs2.cpp | 10 +- .../project.pbxproj | 2 + .../project.pbxproj | 2 + .../AudioPluginHost.xcodeproj/project.pbxproj | 2 + .../AudioPluginHost.xcodeproj/project.pbxproj | 2 + .../BinaryBuilder.xcodeproj/project.pbxproj | 2 + .../project.pbxproj | 2 + .../project.pbxproj | 2 + .../ProjectSaving/jucer_ProjectExport_Xcode.h | 38 +- .../UnitTestRunner.xcodeproj/project.pbxproj | 2 + .../processors/juce_AudioProcessor.h | 12 - .../juce_blocks_basics/juce_blocks_basics.cpp | 4 +- .../juce_blocks_basics/juce_blocks_basics.h | 4 +- modules/juce_core/containers/juce_Array.h | 4 - .../juce_core/containers/juce_OwnedArray.h | 10 +- modules/juce_core/memory/juce_Atomic.h | 503 ++++-------------- .../juce_core/system/juce_CompilerSupport.h | 30 +- .../juce_core/system/juce_StandardHeader.h | 11 +- modules/juce_core/text/juce_String.h | 2 +- modules/juce_core/text/juce_StringArray.cpp | 2 - modules/juce_core/text/juce_StringArray.h | 3 +- .../values/juce_ValueTree.cpp | 2 - .../values/juce_ValueTree.h | 2 - modules/juce_dsp/juce_dsp.cpp | 4 +- modules/juce_dsp/juce_dsp.h | 4 +- modules/juce_gui_basics/juce_gui_basics.cpp | 15 +- modules/juce_gui_basics/juce_gui_basics.h | 15 +- modules/juce_osc/juce_osc.cpp | 8 - modules/juce_osc/juce_osc.h | 8 - 33 files changed, 198 insertions(+), 548 deletions(-) diff --git a/BREAKING-CHANGES.txt b/BREAKING-CHANGES.txt index ebda76b58181..ee39738aa4d4 100644 --- a/BREAKING-CHANGES.txt +++ b/BREAKING-CHANGES.txt @@ -4,6 +4,27 @@ JUCE breaking changes Develop ======= +Change +------ +JUCE no longer supports OS X deployment targets earlier than 10.7. + +Possible Issues +--------------- +If you were previously targeting OS X 10.5 or 10.6 you will no longer be able +to build JUCE-based products compatible with those platforms. + +Workaround +---------- +None. With the appropriate JUCE licence you may be able to backport new JUCE +features, but there will be no official support for this. + +Rationale +--------- +Increasing the minimum supported OS X version allows the JUCE codebase to make +use of the more modern C++ features found in the 10.7 standard library, which +in turn will increase thread and memory safety. + + Version 5.3.0 ============= @@ -75,8 +96,8 @@ InAppPurchases object yourself. Possible Issues --------------- -Any code using InAppPurchases needs to be updated to retrieve a singleton pointer -to InAppPurchases. +Any code using InAppPurchases needs to be updated to retrieve a singleton +pointer to InAppPurchases. Workaround ---------- diff --git a/examples/DemoRunner/Builds/MacOSX/DemoRunner.xcodeproj/project.pbxproj b/examples/DemoRunner/Builds/MacOSX/DemoRunner.xcodeproj/project.pbxproj index 653ebd669622..1b3eccfa5034 100644 --- a/examples/DemoRunner/Builds/MacOSX/DemoRunner.xcodeproj/project.pbxproj +++ b/examples/DemoRunner/Builds/MacOSX/DemoRunner.xcodeproj/project.pbxproj @@ -214,6 +214,7 @@ BFDAF16175D03695EEB466BC, ); name = Source; sourceTree = ""; }; B18D059E5616FA729F764229 = {isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; @@ -248,6 +249,7 @@ USE_HEADERMAP = NO; }; name = Debug; }; 69330F27DD2C71609336C7D2 = {isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; diff --git a/examples/DemoRunner/Builds/iOS/DemoRunner.xcodeproj/project.pbxproj b/examples/DemoRunner/Builds/iOS/DemoRunner.xcodeproj/project.pbxproj index 8cfa741cdbcb..7d6730e02ba4 100644 --- a/examples/DemoRunner/Builds/iOS/DemoRunner.xcodeproj/project.pbxproj +++ b/examples/DemoRunner/Builds/iOS/DemoRunner.xcodeproj/project.pbxproj @@ -227,6 +227,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; CODE_SIGN_ENTITLEMENTS = "DemoRunner.entitlements"; COMBINE_HIDPI_IMAGES = YES; @@ -260,6 +261,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; CODE_SIGN_ENTITLEMENTS = "DemoRunner.entitlements"; COMBINE_HIDPI_IMAGES = YES; diff --git a/examples/DemoRunner/Source/Demos/DemoPIPs1.cpp b/examples/DemoRunner/Source/Demos/DemoPIPs1.cpp index c79f07bfca62..dc4577d411cf 100644 --- a/examples/DemoRunner/Source/Demos/DemoPIPs1.cpp +++ b/examples/DemoRunner/Source/Demos/DemoPIPs1.cpp @@ -42,7 +42,7 @@ #include "../../../Audio/MPEDemo.h" #include "../../../Audio/PluckedStringsDemo.h" -#if (defined (JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT)) && (defined (JUCE_HAS_CONSTEXPR)) +#if JUCE_HAS_CONSTEXPR #include "../../../Audio/SimpleFFTDemo.h" #include "../../../BLOCKS/BlocksDrawingDemo.h" #include "../../../BLOCKS/BlocksMonitorDemo.h" @@ -71,9 +71,7 @@ #include "../../../Utilities/LiveConstantDemo.h" #include "../../../Utilities/MultithreadingDemo.h" #include "../../../Utilities/NetworkingDemo.h" -#if defined (JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT) - #include "../../../Utilities/OSCDemo.h" -#endif +#include "../../../Utilities/OSCDemo.h" #include "../../../Utilities/SystemInfoDemo.h" #include "../../../Utilities/TimersAndEventsDemo.h" #include "../../../Utilities/UnitTestsDemo.h" @@ -92,7 +90,7 @@ void registerDemos_One() noexcept REGISTER_DEMO (MPEDemo, Audio, false) REGISTER_DEMO (PluckedStringsDemo, Audio, false) - #if (defined (JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT)) && (defined (JUCE_HAS_CONSTEXPR)) + #if JUCE_HAS_CONSTEXPR REGISTER_DEMO (SimpleFFTDemo, Audio, false) REGISTER_DEMO (BlocksDrawingDemo, BLOCKS, false) REGISTER_DEMO (BlocksMonitorDemo, BLOCKS, false) @@ -120,9 +118,7 @@ void registerDemos_One() noexcept REGISTER_DEMO (LiveConstantDemo, Utilities, false) REGISTER_DEMO (MultithreadingDemo, Utilities, false) REGISTER_DEMO (NetworkingDemo, Utilities, false) - #if defined (JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT) REGISTER_DEMO (OSCDemo, Utilities, false) - #endif REGISTER_DEMO (SystemInfoDemo, Utilities, false) REGISTER_DEMO (TimersAndEventsDemo, Utilities, false) REGISTER_DEMO_WITH_FILENAME (UnitTestClasses::UnitTestsDemo, Utilities, UnitTestsDemo, false) diff --git a/examples/DemoRunner/Source/Demos/DemoPIPs2.cpp b/examples/DemoRunner/Source/Demos/DemoPIPs2.cpp index 243724b69308..588d5b997f54 100644 --- a/examples/DemoRunner/Source/Demos/DemoPIPs2.cpp +++ b/examples/DemoRunner/Source/Demos/DemoPIPs2.cpp @@ -43,12 +43,10 @@ #include "../../../GUI/ComponentDemo.h" #include "../../../GUI/ComponentTransformsDemo.h" #include "../../../GUI/DialogsDemo.h" -#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS - #include "../../../GUI/FlexBoxDemo.h" -#endif +#include "../../../GUI/FlexBoxDemo.h" #include "../../../GUI/FontsDemo.h" #include "../../../GUI/GraphicsDemo.h" -#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS && JUCE_HAS_CONSTEXPR +#if JUCE_HAS_CONSTEXPR #include "../../../GUI/GridDemo.h" #endif #include "../../../GUI/ImagesDemo.h" @@ -84,12 +82,10 @@ void registerDemos_Two() noexcept REGISTER_DEMO (ComponentDemo, GUI, false) REGISTER_DEMO (ComponentTransformsDemo, GUI, false) REGISTER_DEMO (DialogsDemo, GUI, false) - #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS REGISTER_DEMO (FlexBoxDemo, GUI, false) - #endif REGISTER_DEMO (FontsDemo, GUI, false) REGISTER_DEMO (GraphicsDemo, GUI, false) - #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS && JUCE_HAS_CONSTEXPR + #if JUCE_HAS_CONSTEXPR REGISTER_DEMO (GridDemo, GUI, false) #endif REGISTER_DEMO (ImagesDemo, GUI, false) diff --git a/extras/AudioPerformanceTest/Builds/MacOSX/AudioPerformanceTest.xcodeproj/project.pbxproj b/extras/AudioPerformanceTest/Builds/MacOSX/AudioPerformanceTest.xcodeproj/project.pbxproj index 5d07907ee2be..7f38502a1456 100644 --- a/extras/AudioPerformanceTest/Builds/MacOSX/AudioPerformanceTest.xcodeproj/project.pbxproj +++ b/extras/AudioPerformanceTest/Builds/MacOSX/AudioPerformanceTest.xcodeproj/project.pbxproj @@ -125,6 +125,7 @@ 1DFEAF972822E305E013CC06, ); name = Source; sourceTree = ""; }; 19B7C16D592FB25D09022191 = {isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; @@ -156,6 +157,7 @@ USE_HEADERMAP = NO; }; name = Debug; }; B7A6988E30C0A68B01EDC53B = {isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; diff --git a/extras/AudioPerformanceTest/Builds/iOS/AudioPerformanceTest.xcodeproj/project.pbxproj b/extras/AudioPerformanceTest/Builds/iOS/AudioPerformanceTest.xcodeproj/project.pbxproj index 8f8c60a34b8c..6e39bf51d43d 100644 --- a/extras/AudioPerformanceTest/Builds/iOS/AudioPerformanceTest.xcodeproj/project.pbxproj +++ b/extras/AudioPerformanceTest/Builds/iOS/AudioPerformanceTest.xcodeproj/project.pbxproj @@ -136,6 +136,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; @@ -166,6 +167,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; diff --git a/extras/AudioPluginHost/Builds/MacOSX/AudioPluginHost.xcodeproj/project.pbxproj b/extras/AudioPluginHost/Builds/MacOSX/AudioPluginHost.xcodeproj/project.pbxproj index 49c55a8727db..58f02ecb50ee 100644 --- a/extras/AudioPluginHost/Builds/MacOSX/AudioPluginHost.xcodeproj/project.pbxproj +++ b/extras/AudioPluginHost/Builds/MacOSX/AudioPluginHost.xcodeproj/project.pbxproj @@ -197,6 +197,7 @@ D85C0D11EE4F6C73B9EB5BCD, ); name = Source; sourceTree = ""; }; C8B793AC1BEFBE7A99BE8352 = {isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; @@ -229,6 +230,7 @@ USE_HEADERMAP = NO; }; name = Debug; }; 49453CC5AD9F08D2738464AC = {isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; diff --git a/extras/AudioPluginHost/Builds/iOS/AudioPluginHost.xcodeproj/project.pbxproj b/extras/AudioPluginHost/Builds/iOS/AudioPluginHost.xcodeproj/project.pbxproj index ec7353fcfe74..a3452b3e1aa8 100644 --- a/extras/AudioPluginHost/Builds/iOS/AudioPluginHost.xcodeproj/project.pbxproj +++ b/extras/AudioPluginHost/Builds/iOS/AudioPluginHost.xcodeproj/project.pbxproj @@ -199,6 +199,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; @@ -229,6 +230,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; diff --git a/extras/BinaryBuilder/Builds/MacOSX/BinaryBuilder.xcodeproj/project.pbxproj b/extras/BinaryBuilder/Builds/MacOSX/BinaryBuilder.xcodeproj/project.pbxproj index 75dc7c18f9b5..a88b226942da 100644 --- a/extras/BinaryBuilder/Builds/MacOSX/BinaryBuilder.xcodeproj/project.pbxproj +++ b/extras/BinaryBuilder/Builds/MacOSX/BinaryBuilder.xcodeproj/project.pbxproj @@ -47,6 +47,7 @@ 70A875922C34E55D4F48A196, ); name = Source; sourceTree = ""; }; 00F18709927DE6070FBA7BD0 = {isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; @@ -76,6 +77,7 @@ USE_HEADERMAP = NO; }; name = Debug; }; 8A190EF24B99F557190320DA = {isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; diff --git a/extras/NetworkGraphicsDemo/Builds/MacOSX/NetworkGraphicsDemo.xcodeproj/project.pbxproj b/extras/NetworkGraphicsDemo/Builds/MacOSX/NetworkGraphicsDemo.xcodeproj/project.pbxproj index db6cdc22fd57..c783ae58a444 100644 --- a/extras/NetworkGraphicsDemo/Builds/MacOSX/NetworkGraphicsDemo.xcodeproj/project.pbxproj +++ b/extras/NetworkGraphicsDemo/Builds/MacOSX/NetworkGraphicsDemo.xcodeproj/project.pbxproj @@ -159,6 +159,7 @@ 8B59A884C62D960EE9DFEF47, ); name = Source; sourceTree = ""; }; EE7498599191DDC73ECB55B0 = {isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; @@ -190,6 +191,7 @@ USE_HEADERMAP = NO; }; name = Debug; }; 2E06386CE7CCA5FF76819BFF = {isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; diff --git a/extras/NetworkGraphicsDemo/Builds/iOS/NetworkGraphicsDemo.xcodeproj/project.pbxproj b/extras/NetworkGraphicsDemo/Builds/iOS/NetworkGraphicsDemo.xcodeproj/project.pbxproj index 1091c3e111e5..590ad9014c9f 100644 --- a/extras/NetworkGraphicsDemo/Builds/iOS/NetworkGraphicsDemo.xcodeproj/project.pbxproj +++ b/extras/NetworkGraphicsDemo/Builds/iOS/NetworkGraphicsDemo.xcodeproj/project.pbxproj @@ -170,6 +170,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; @@ -200,6 +201,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h index 35329e182f62..79e7bdf916ee 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h @@ -33,7 +33,7 @@ namespace const char* const osxVersionDefault = "10.11"; const char* const iosVersionDefault = "9.3"; - const int oldestSDKVersion = 5; + const int oldestSDKVersion = 7; const int currentSDKVersion = 13; const int minimumAUv3SDKVersion = 11; @@ -421,7 +421,6 @@ class XcodeProjectExporter : public ProjectExporter osxArchitecture (config, Ids::osxArchitecture, getUndoManager(), osxArch_Default), customXcodeFlags (config, Ids::customXcodeFlags, getUndoManager()), plistPreprocessorDefinitions (config, Ids::plistPreprocessorDefinitions, getUndoManager()), - cppStandardLibrary (config, Ids::cppLibType, getUndoManager()), codeSignIdentity (config, Ids::codeSigningIdentity, getUndoManager(), iOS ? "iPhone Developer" : "Mac Developer"), fastMathEnabled (config, Ids::fastMath, getUndoManager()), stripLocalSymbolsEnabled (config, Ids::stripLocalSymbols, getUndoManager()), @@ -487,11 +486,6 @@ class XcodeProjectExporter : public ProjectExporter props.add (new TextPropertyComponent (plistPreprocessorDefinitions, "PList Preprocessor Definitions", 2048, true), "Preprocessor definitions used during PList preprocessing (see PList Preprocess)."); - props.add (new ChoicePropertyComponent (cppStandardLibrary, "C++ Library", - { "LLVM libc++", "GNU libstdc++" }, - { "libc++", "libstdc++" }), - "The type of C++ std lib that will be linked."); - props.add (new TextPropertyComponent (codeSignIdentity, "Code-Signing Identity", 1024, false), "The name of a code-signing identity for Xcode to apply."); @@ -514,8 +508,6 @@ class XcodeProjectExporter : public ProjectExporter bool isFastMathEnabled() const { return fastMathEnabled.get(); } - String getCPPStandardLibraryString() const { return cppStandardLibrary.get(); } - bool isStripLocalSymbolsEnabled() const { return stripLocalSymbolsEnabled.get(); } String getCustomXcodeFlagsString() const { return customXcodeFlags.get(); } @@ -540,7 +532,7 @@ class XcodeProjectExporter : public ProjectExporter bool iOS; ValueWithDefault osxSDKVersion, osxDeploymentTarget, iosDeploymentTarget, osxArchitecture, - customXcodeFlags, plistPreprocessorDefinitions, cppStandardLibrary, codeSignIdentity, + customXcodeFlags, plistPreprocessorDefinitions, codeSignIdentity, fastMathEnabled, stripLocalSymbolsEnabled, pluginBinaryCopyStepEnabled, vstBinaryLocation, vst3BinaryLocation, auBinaryLocation, rtasBinaryLocation, aaxBinaryLocation; @@ -1129,8 +1121,7 @@ class XcodeProjectExporter : public ProjectExporter : "c++") + cppStandard).quoted()); } - if (config.getCPPStandardLibraryString().isNotEmpty()) - s.set ("CLANG_CXX_LIBRARY", config.getCPPStandardLibraryString().quoted()); + s.set ("CLANG_CXX_LIBRARY", "\"libc++\""); s.set ("COMBINE_HIDPI_IMAGES", "YES"); @@ -1577,8 +1568,8 @@ class XcodeProjectExporter : public ProjectExporter = RelativePath (owner.getAAXPathValue().toString(), RelativePath::projectFolder) .getChildFile ("Libs"); - String libraryPath (config.isDebug() ? "Debug/libAAXLibrary" : "Release/libAAXLibrary"); - libraryPath += (isUsingClangCppLibrary (config) ? "_libcpp.a" : ".a"); + String libraryPath (config.isDebug() ? "Debug" : "Release"); + libraryPath += "/libAAXLibrary_libcpp.a"; extraLibs.add (aaxLibsFolder.getChildFile (libraryPath)); } @@ -1639,25 +1630,6 @@ class XcodeProjectExporter : public ProjectExporter return targetExtraSearchPaths; } - bool isUsingClangCppLibrary (const BuildConfiguration& config) const - { - if (auto xcodeConfig = dynamic_cast (&config)) - { - auto configValue = xcodeConfig->getCPPStandardLibraryString(); - - if (configValue.isNotEmpty()) - return (configValue == "libc++"); - - auto minorOSXDeploymentTarget = getOSXDeploymentTarget (*xcodeConfig) - .fromLastOccurrenceOf (".", false, false) - .getIntValue(); - - return (minorOSXDeploymentTarget > 8); - } - - return false; - } - String getOSXDeploymentTarget (const XcodeBuildConfiguration& config, String* sdkRoot = nullptr) const { auto sdk = config.getOSXSDKVersionString(); diff --git a/extras/UnitTestRunner/Builds/MacOSX/UnitTestRunner.xcodeproj/project.pbxproj b/extras/UnitTestRunner/Builds/MacOSX/UnitTestRunner.xcodeproj/project.pbxproj index dc126960b1d5..25eacd702bd7 100644 --- a/extras/UnitTestRunner/Builds/MacOSX/UnitTestRunner.xcodeproj/project.pbxproj +++ b/extras/UnitTestRunner/Builds/MacOSX/UnitTestRunner.xcodeproj/project.pbxproj @@ -173,6 +173,7 @@ 6D697538ADDCFBB6C79AC6C6, ); name = Source; sourceTree = ""; }; A81C9C5D3696F83D5E8CFE11 = {isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; @@ -204,6 +205,7 @@ USE_HEADERMAP = NO; }; name = Debug; }; 962CC7E0A536C3F56DBE1F8F = {isa = XCBuildConfiguration; buildSettings = { CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/modules/juce_audio_processors/processors/juce_AudioProcessor.h index 11122fc04868..201f3b363644 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -66,18 +66,10 @@ class JUCE_API AudioProcessor /** Constructor for AudioProcessors which use layout maps If your AudioProcessor uses layout maps then use this constructor. */ - #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS AudioProcessor (const std::initializer_list& channelLayoutList) : AudioProcessor (busesPropertiesFromLayoutArray (layoutListToArray (channelLayoutList))) { } - #else - template - AudioProcessor (const short (&channelLayoutList) [numLayouts][2]) - : AudioProcessor (busesPropertiesFromLayoutArray (layoutListToArray (channelLayoutList))) - { - } - #endif public: //============================================================================== @@ -766,12 +758,10 @@ class JUCE_API AudioProcessor } @endcode */ - #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS static bool containsLayout (const BusesLayout& layouts, const std::initializer_list& channelLayoutList) { return containsLayout (layouts, layoutListToArray (channelLayoutList)); } - #endif template static bool containsLayout (const BusesLayout& layouts, const short (&channelLayoutList) [numLayouts][2]) @@ -1590,7 +1580,6 @@ class JUCE_API AudioProcessor return layouts; } - #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS static Array layoutListToArray (const std::initializer_list& configuration) { Array layouts; @@ -1600,7 +1589,6 @@ class JUCE_API AudioProcessor return layouts; } - #endif //============================================================================== static BusesProperties busesPropertiesFromLayoutArray (const Array&); diff --git a/modules/juce_blocks_basics/juce_blocks_basics.cpp b/modules/juce_blocks_basics/juce_blocks_basics.cpp index 15e4a18c1062..fcd764b24fa3 100644 --- a/modules/juce_blocks_basics/juce_blocks_basics.cpp +++ b/modules/juce_blocks_basics/juce_blocks_basics.cpp @@ -22,9 +22,9 @@ #include "juce_blocks_basics.h" -#if (! defined (JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT)) || (! defined (JUCE_HAS_CONSTEXPR)) +#if ! JUCE_HAS_CONSTEXPR #ifndef JUCE_DEMO_RUNNER - #error "juce_blocks_basics module requires your compiler to have a newer version of the standard library" + #error "The juce_blocks_basics module requires a compiler that supports constexpr" #endif #else diff --git a/modules/juce_blocks_basics/juce_blocks_basics.h b/modules/juce_blocks_basics/juce_blocks_basics.h index a260f32de45c..18b95607239f 100644 --- a/modules/juce_blocks_basics/juce_blocks_basics.h +++ b/modules/juce_blocks_basics/juce_blocks_basics.h @@ -50,9 +50,9 @@ #include #include -#if (! defined (JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT)) || (! defined (JUCE_HAS_CONSTEXPR)) +#if ! JUCE_HAS_CONSTEXPR #ifndef JUCE_DEMO_RUNNER - #error "juce_blocks_basics module requires your compiler to have a newer version of the standard library" + #error "The juce_blocks_basics module requires a compiler that supports constexpr" #endif #else diff --git a/modules/juce_core/containers/juce_Array.h b/modules/juce_core/containers/juce_Array.h index cce599f4d0e9..0385da4c0792 100644 --- a/modules/juce_core/containers/juce_Array.h +++ b/modules/juce_core/containers/juce_Array.h @@ -135,13 +135,11 @@ class Array addAssumingCapacityIsReady (static_cast (firstNewElement), otherElements...); } - #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS template Array (const std::initializer_list& items) { addArray (items); } - #endif /** Destructor. */ ~Array() @@ -658,7 +656,6 @@ class Array } } - #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS template void addArray (const std::initializer_list& items) { @@ -671,7 +668,6 @@ class Array ++numUsed; } } - #endif /** Adds elements from a null-terminated array of pointers to the end of this array. diff --git a/modules/juce_core/containers/juce_OwnedArray.h b/modules/juce_core/containers/juce_OwnedArray.h index de71c7274a14..e5a6e5b41549 100644 --- a/modules/juce_core/containers/juce_OwnedArray.h +++ b/modules/juce_core/containers/juce_OwnedArray.h @@ -66,7 +66,7 @@ class OwnedArray deleteAllObjects(); } - /** Move constructor */ + /** Move constructor. */ OwnedArray (OwnedArray&& other) noexcept : data (static_cast&&> (other.data)), numUsed (other.numUsed) @@ -74,14 +74,13 @@ class OwnedArray other.numUsed = 0; } - #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS + /** Creates an array from a list of objects. */ OwnedArray (const std::initializer_list& items) { addArray (items); } - #endif - /** Move assignment operator */ + /** Move assignment operator. */ OwnedArray& operator= (OwnedArray&& other) noexcept { const ScopedLockType lock (getLock()); @@ -478,7 +477,7 @@ class OwnedArray } } - #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS + /** Adds elements from another array to the end of this array. */ template void addArray (const std::initializer_list& items) { @@ -491,7 +490,6 @@ class OwnedArray ++numUsed; } } - #endif /** Adds copies of the elements in another array to the end of this array. diff --git a/modules/juce_core/memory/juce_Atomic.h b/modules/juce_core/memory/juce_Atomic.h index 9e9a7ec1b0d0..f1bba1d09e52 100644 --- a/modules/juce_core/memory/juce_Atomic.h +++ b/modules/juce_core/memory/juce_Atomic.h @@ -31,401 +31,116 @@ namespace juce } #endif -#if JUCE_ATOMIC_AVAILABLE - //============================================================================== - /** - A simple wrapper around std::atomic. - - @tags{Core} - */ - template - struct Atomic final - { - typedef typename AtomicHelpers::DiffTypeHelper::Type DiffType; - - /** Creates a new value, initialised to zero. */ - Atomic() noexcept : value (0) {} - - /** Creates a new value, with a given initial value. */ - Atomic (Type initialValue) noexcept : value (initialValue) {} - - /** Copies another value (atomically). */ - Atomic (const Atomic& other) noexcept : value (other.get()) {} - - /** Destructor. */ - ~Atomic() noexcept - { - #if __cpp_lib_atomic_is_always_lock_free - static_assert (std::atomic::is_always_lock_free, - "This class can only be used for lock-free types"); - #endif - } - - /** Atomically reads and returns the current value. */ - Type get() const noexcept { return value.load(); } - - /** Atomically sets the current value. */ - void set (Type newValue) noexcept { value = newValue; } - - /** Atomically sets the current value, returning the value that was replaced. */ - Type exchange (Type newValue) noexcept { return value.exchange (newValue); } - - /** Atomically compares this value with a target value, and if it is equal, sets - this to be equal to a new value. - - This operation is the atomic equivalent of doing this: - @code - bool compareAndSetBool (Type newValue, Type valueToCompare) - { - if (get() == valueToCompare) - { - set (newValue); - return true; - } - - return false; - } - @endcode - - Internally, this method calls std::atomic::compare_exchange_strong with - memory_order_seq_cst (the strictest std::memory_order). - - @returns true if the comparison was true and the value was replaced; false if - the comparison failed and the value was left unchanged. - @see compareAndSetValue - */ - bool compareAndSetBool (Type newValue, Type valueToCompare) noexcept - { - return value.compare_exchange_strong (valueToCompare, newValue); - } - - /** Copies another value into this one (atomically). */ - Atomic& operator= (const Atomic& other) noexcept - { - value = other.value.load(); - return *this; - } - - /** Copies another value into this one (atomically). */ - Atomic& operator= (Type newValue) noexcept - { - value = newValue; - return *this; - } - - /** Atomically adds a number to this value, returning the new value. */ - Type operator+= (DiffType amountToAdd) noexcept { return value += amountToAdd; } - - /** Atomically subtracts a number from this value, returning the new value. */ - Type operator-= (DiffType amountToSubtract) noexcept { return value -= amountToSubtract; } - - /** Atomically increments this value, returning the new value. */ - Type operator++() noexcept { return ++value; } - - /** Atomically decrements this value, returning the new value. */ - Type operator--() noexcept { return --value; } - - /** Implements a memory read/write barrier. - - Internally this calls std::atomic_thread_fence with - memory_order_seq_cst (the strictest std::memory_order). - */ - void memoryBarrier() noexcept { atomic_thread_fence (std::memory_order_seq_cst); } - - /** The std::atomic object that this class operates on. */ - std::atomic value; - - //============================================================================== - #ifndef DOXYGEN - /* This method has been deprecated as there is no equivalent method in - std::atomic. Use compareAndSetBool instead. - */ - JUCE_DEPRECATED (Type compareAndSetValue (Type, Type) noexcept); - #endif - }; - -#else - - #if JUCE_MSVC - JUCE_COMPILER_WARNING ("You must use a version of MSVC which supports std::atomic") - #endif - - #if JUCE_IOS || JUCE_ANDROID // (64-bit ops will compile but not link) - #define JUCE_64BIT_ATOMICS_UNAVAILABLE 1 - #endif - - #ifndef DOXYGEN - template class AtomicBase; - #endif - - //============================================================================== - /** - Simple class to hold a primitive value and perform atomic operations on it. - - The type used must be a 32 or 64 bit primitive, like an int, pointer, etc. - There are methods to perform most of the basic atomic operations. - - @tags{Core} - */ - template - class Atomic final : public AtomicBase - { - public: - /** Resulting type when subtracting the underlying Type. */ - typedef typename AtomicBase::DiffType DiffType; - - /** Creates a new value, initialised to zero. */ - inline Atomic() noexcept {} - - /** Creates a new value, with a given initial value. */ - inline explicit Atomic (const Type initialValue) noexcept : AtomicBase (initialValue) {} - - /** Copies another value (atomically). */ - inline Atomic (const Atomic& other) noexcept : AtomicBase (other) {} - - /** Destructor. */ - inline ~Atomic() noexcept - { - static_assert (sizeof (Type) == 4 || sizeof (Type) == 8, - "Atomic can only be used for types which are 32 or 64 bits in size"); - } - - /** Atomically reads and returns the current value. */ - inline Type get() const noexcept { return AtomicBase::get(); } - - /** Copies another value into this one (atomically). */ - inline Atomic& operator= (const Atomic& other) noexcept { AtomicBase::operator= (other); return *this; } - - /** Copies another value into this one (atomically). */ - inline Atomic& operator= (const Type newValue) noexcept { AtomicBase::operator= (newValue); return *this; } - - /** Atomically sets the current value. */ - inline void set (Type newValue) noexcept { exchange (newValue); } - - /** Atomically sets the current value, returning the value that was replaced. */ - inline Type exchange (Type v) noexcept { return AtomicBase::exchange (v); } - - /** Atomically adds a number to this value, returning the new value. */ - Type operator+= (DiffType amountToAdd) noexcept; - - /** Atomically subtracts a number from this value, returning the new value. */ - Type operator-= (DiffType amountToSubtract) noexcept; - - /** Atomically increments this value, returning the new value. */ - Type operator++() noexcept; - - /** Atomically decrements this value, returning the new value. */ - Type operator--() noexcept; - - /** Atomically compares this value with a target value, and if it is equal, sets - this to be equal to a new value. - - This operation is the atomic equivalent of doing this: - @code - bool compareAndSetBool (Type newValue, Type valueToCompare) - { - if (get() == valueToCompare) - { - set (newValue); - return true; - } - - return false; - } - @endcode - - @returns true if the comparison was true and the value was replaced; false if - the comparison failed and the value was left unchanged. - @see compareAndSetValue - */ - inline bool compareAndSetBool (Type newValue, Type valueToCompare) noexcept { return AtomicBase::compareAndSetBool (newValue, valueToCompare); } - - /** Atomically compares this value with a target value, and if it is equal, sets - this to be equal to a new value. - - This operation is the atomic equivalent of doing this: - @code - Type compareAndSetValue (Type newValue, Type valueToCompare) - { - Type oldValue = get(); - if (oldValue == valueToCompare) - set (newValue); - - return oldValue; - } - @endcode - - @returns the old value before it was changed. - @see compareAndSetBool - */ - inline Type compareAndSetValue (Type newValue, Type valueToCompare) noexcept { return AtomicBase::compareAndSetValue (newValue, valueToCompare); } - - /** Implements a memory read/write barrier. */ - static inline void memoryBarrier() noexcept { AtomicBase::memoryBarrier(); } - }; - - #if ! DOXYGEN +//============================================================================== +/** + A simple wrapper around std::atomic. - //============================================================================== - // Internal implementation follows - //============================================================================== - template - class AtomicBase - { - public: - typedef typename AtomicHelpers::DiffTypeHelper::Type DiffType; - - inline AtomicBase() noexcept : value (0) {} - inline explicit AtomicBase (const Type v) noexcept : value (v) {} - inline AtomicBase (const AtomicBase& other) noexcept : value (other.get()) {} - Type get() const noexcept; - inline AtomicBase& operator= (const AtomicBase& other) noexcept { exchange (other.get()); return *this; } - inline AtomicBase& operator= (const Type newValue) noexcept { exchange (newValue); return *this; } - void set (Type newValue) noexcept { exchange (newValue); } - Type exchange (Type) noexcept; - bool compareAndSetBool (Type, Type) noexcept; - Type compareAndSetValue (Type, Type) noexcept; - static void memoryBarrier() noexcept; - - //============================================================================== - #if JUCE_64BIT - JUCE_ALIGN (8) - #else - JUCE_ALIGN (4) - #endif - - /** The raw value that this class operates on. - This is exposed publicly in case you need to manipulate it directly - for performance reasons. + @tags{Core} +*/ +template +struct Atomic final +{ + typedef typename AtomicHelpers::DiffTypeHelper::Type DiffType; + + /** Creates a new value, initialised to zero. */ + Atomic() noexcept : value (0) {} + + /** Creates a new value, with a given initial value. */ + Atomic (Type initialValue) noexcept : value (initialValue) {} + + /** Copies another value (atomically). */ + Atomic (const Atomic& other) noexcept : value (other.get()) {} + + /** Destructor. */ + ~Atomic() noexcept + { + #if __cpp_lib_atomic_is_always_lock_free + static_assert (std::atomic::is_always_lock_free, + "This class can only be used for lock-free types"); + #endif + } + + /** Atomically reads and returns the current value. */ + Type get() const noexcept { return value.load(); } + + /** Atomically sets the current value. */ + void set (Type newValue) noexcept { value = newValue; } + + /** Atomically sets the current value, returning the value that was replaced. */ + Type exchange (Type newValue) noexcept { return value.exchange (newValue); } + + /** Atomically compares this value with a target value, and if it is equal, sets + this to be equal to a new value. + + This operation is the atomic equivalent of doing this: + @code + bool compareAndSetBool (Type newValue, Type valueToCompare) + { + if (get() == valueToCompare) + { + set (newValue); + return true; + } + + return false; + } + @endcode + + Internally, this method calls std::atomic::compare_exchange_strong with + memory_order_seq_cst (the strictest std::memory_order). + + @returns true if the comparison was true and the value was replaced; false if + the comparison failed and the value was left unchanged. + @see compareAndSetValue + */ + bool compareAndSetBool (Type newValue, Type valueToCompare) noexcept + { + return value.compare_exchange_strong (valueToCompare, newValue); + } + + /** Copies another value into this one (atomically). */ + Atomic& operator= (const Atomic& other) noexcept + { + value = other.value.load(); + return *this; + } + + /** Copies another value into this one (atomically). */ + Atomic& operator= (Type newValue) noexcept + { + value = newValue; + return *this; + } + + /** Atomically adds a number to this value, returning the new value. */ + Type operator+= (DiffType amountToAdd) noexcept { return value += amountToAdd; } + + /** Atomically subtracts a number from this value, returning the new value. */ + Type operator-= (DiffType amountToSubtract) noexcept { return value -= amountToSubtract; } + + /** Atomically increments this value, returning the new value. */ + Type operator++() noexcept { return ++value; } + + /** Atomically decrements this value, returning the new value. */ + Type operator--() noexcept { return --value; } + + /** Implements a memory read/write barrier. + + Internally this calls std::atomic_thread_fence with + memory_order_seq_cst (the strictest std::memory_order). */ - volatile Type value; - - protected: - template - static inline Dest castTo (Source value) noexcept { union { Dest d; Source s; } u; u.s = value; return u.d; } - - static inline Type castFrom32Bit (int32 value) noexcept { return castTo (value); } - static inline Type castFrom64Bit (int64 value) noexcept { return castTo (value); } - static inline int32 castTo32Bit (Type value) noexcept { return castTo (value); } - static inline int64 castTo64Bit (Type value) noexcept { return castTo (value); } - - Type operator++ (int); // better to just use pre-increment with atomics.. - Type operator-- (int); - - /** This templated negate function will negate pointers as well as integers */ - template - inline ValueType negateValue (ValueType n) noexcept - { - return sizeof (ValueType) == 1 ? (ValueType) -(signed char) n - : (sizeof (ValueType) == 2 ? (ValueType) -(short) n - : (sizeof (ValueType) == 4 ? (ValueType) -(int) n - : ((ValueType) -(int64) n))); - } - - /** This templated negate function will negate pointers as well as integers */ - template - inline PointerType* negateValue (PointerType* n) noexcept - { - return reinterpret_cast (-reinterpret_cast (n)); - } - }; - - //============================================================================== - // Specialisation for void* which does not include the pointer arithmetic - template <> - class Atomic : public AtomicBase - { - public: - inline Atomic() noexcept {} - inline explicit Atomic (void* const initialValue) noexcept : AtomicBase (initialValue) {} - inline Atomic (const Atomic& other) noexcept : AtomicBase (other) {} - inline void* get() const noexcept { return AtomicBase::get(); } - inline Atomic& operator= (const Atomic& other) noexcept { AtomicBase::operator= (other); return *this; } - inline Atomic& operator= (void* const newValue) noexcept { AtomicBase::operator= (newValue); return *this; } - inline void set (void* newValue) noexcept { exchange (newValue); } - inline void* exchange (void* v) noexcept { return AtomicBase::exchange (v); } - inline bool compareAndSetBool (void* newValue, void* valueToCompare) noexcept { return AtomicBase::compareAndSetBool (newValue, valueToCompare); } - inline void* compareAndSetValue (void* newValue, void* valueToCompare) noexcept { return AtomicBase::compareAndSetValue (newValue, valueToCompare); } - static inline void memoryBarrier() noexcept { AtomicBase::memoryBarrier(); } - }; - - template - struct AtomicIncrementDecrement - { - static inline Type inc (AtomicBase& a) noexcept - { - return sizeof (Type) == 4 ? (Type) __sync_add_and_fetch (& (a.value), (Type) 1) - : (Type) __sync_add_and_fetch ((int64_t*) & (a.value), 1); - } - - static inline Type dec (AtomicBase& a) noexcept - { - return sizeof (Type) == 4 ? (Type) __sync_add_and_fetch (& (a.value), (Type) -1) - : (Type) __sync_add_and_fetch ((int64_t*) & (a.value), -1); - } - }; - - template - struct AtomicIncrementDecrement - { - static inline Type* inc (Atomic& a) noexcept { return a.operator+= (1); } - static inline Type* dec (Atomic& a) noexcept { return a.operator-= (1); } - }; - - //============================================================================== - template - inline Type AtomicBase::get() const noexcept - { - return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_add_and_fetch ((volatile int32*) &value, 0)) - : castFrom64Bit ((int64) __sync_add_and_fetch ((volatile int64*) &value, 0)); - } - - template - inline Type AtomicBase::exchange (const Type newValue) noexcept - { - Type currentVal = get(); - while (! compareAndSetBool (newValue, currentVal)) { currentVal = get(); } - return currentVal; - } - - template - inline Type Atomic::operator+= (const DiffType amountToAdd) noexcept - { - Type amount = (Type() + amountToAdd); - return (Type) __sync_add_and_fetch (& (AtomicBase::value), amount); - } - - template - inline Type Atomic::operator-= (const DiffType amountToSubtract) noexcept - { - return operator+= (AtomicBase::negateValue (amountToSubtract)); - } - - template - inline Type Atomic::operator++() noexcept { return AtomicIncrementDecrement::inc (*this); } - - template - inline Type Atomic::operator--() noexcept { return AtomicIncrementDecrement::dec (*this); } - - template - inline bool AtomicBase::compareAndSetBool (const Type newValue, const Type valueToCompare) noexcept - { - return sizeof (Type) == 4 ? __sync_bool_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue)) - : __sync_bool_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue)); - } - - template - inline Type AtomicBase::compareAndSetValue (const Type newValue, const Type valueToCompare) noexcept - { - return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_val_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue))) - : castFrom64Bit ((int64) __sync_val_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue))); - } - - template - inline void AtomicBase::memoryBarrier() noexcept { __sync_synchronize(); } - - #endif // ! DOXYGEN - -#endif + void memoryBarrier() noexcept { atomic_thread_fence (std::memory_order_seq_cst); } + + /** The std::atomic object that this class operates on. */ + std::atomic value; + + //============================================================================== + #ifndef DOXYGEN + /* This method has been deprecated as there is no equivalent method in + std::atomic. Use compareAndSetBool instead. + */ + JUCE_DEPRECATED (Type compareAndSetValue (Type, Type) noexcept); + #endif +}; } // namespace juce diff --git a/modules/juce_core/system/juce_CompilerSupport.h b/modules/juce_core/system/juce_CompilerSupport.h index a441ec7e17c9..09f6f663d989 100644 --- a/modules/juce_core/system/juce_CompilerSupport.h +++ b/modules/juce_core/system/juce_CompilerSupport.h @@ -39,8 +39,6 @@ #endif #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 - #define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1 - #define JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT 1 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 #define JUCE_HAS_CONSTEXPR 1 @@ -68,11 +66,6 @@ #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 #define JUCE_HAS_CONSTEXPR 1 - #if defined (_LIBCPP_VERSION) || ! (JUCE_MAC || JUCE_IOS) - #define JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT 1 - #define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1 - #endif - #ifndef JUCE_COMPILER_SUPPORTS_ARC #define JUCE_COMPILER_SUPPORTS_ARC 1 #endif @@ -96,9 +89,6 @@ #error "JUCE requires Visual Studio 2013 or later" #endif - #define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1 - #define JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT 1 - #if _MSC_VER >= 1900 // VS2015 #define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1 #define JUCE_HAS_CONSTEXPR 1 @@ -118,6 +108,12 @@ #define JUCE_CXX17_IS_AVAILABLE (_MSVC_LANG >= 201703L) #endif +//============================================================================== +// C++ library +#if (defined (__GLIBCXX__) && __GLIBCXX__ < 20130322) || (defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION < 3700)) + #error "JUCE requires a C++ library containing std::atomic" +#endif + //============================================================================== #if JUCE_HAS_CONSTEXPR #define JUCE_CONSTEXPR constexpr @@ -129,18 +125,6 @@ // These are old flags that are now supported on all compatible build targets #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 #define JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES 1 + #define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1 #define JUCE_DELETED_FUNCTION = delete #endif - -//============================================================================== -#if JUCE_ANDROID - #define JUCE_ATOMIC_AVAILABLE 1 -#elif defined(_LIBCPP_VERSION) - #define JUCE_ATOMIC_AVAILABLE (_LIBCPP_VERSION >= 3700) -#elif defined (__GLIBCXX__) - #define JUCE_ATOMIC_AVAILABLE (__GLIBCXX__ >= 20130322) // GCC versions 4.8 and later -#elif defined (_MSC_VER) - #define JUCE_ATOMIC_AVAILABLE 1 // Visual Studio 2013 and later -#else - #define JUCE_ATOMIC_AVAILABLE 0 -#endif diff --git a/modules/juce_core/system/juce_StandardHeader.h b/modules/juce_core/system/juce_StandardHeader.h index f69a05410190..429b7b3b28bd 100644 --- a/modules/juce_core/system/juce_StandardHeader.h +++ b/modules/juce_core/system/juce_StandardHeader.h @@ -50,6 +50,7 @@ #include #include #include +#include //============================================================================== #include "juce_CompilerSupport.h" @@ -108,17 +109,11 @@ #undef minor #undef KeyPress -// Include a replacement for std::function on older platforms and the live -// build -#if JUCE_PROJUCER_LIVE_BUILD || ! defined (JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT) +// Include a replacement for std::function +#if JUCE_PROJUCER_LIVE_BUILD #include "../misc/juce_StdFunctionCompat.h" #endif -// Include std::atomic if it's supported by the compiler -#if JUCE_ATOMIC_AVAILABLE - #include -#endif - //============================================================================== // DLL building settings on Windows #if JUCE_MSVC diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index 1a8c03e8468b..49686752fb23 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -1417,7 +1417,7 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, StringRef } // namespace juce -#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS && ! DOXYGEN // just used to avoid compiling this under compilers that lack libc++ +#if ! DOXYGEN namespace std { template <> struct hash diff --git a/modules/juce_core/text/juce_StringArray.cpp b/modules/juce_core/text/juce_StringArray.cpp index 7f11498b8b44..4029231dec1b 100644 --- a/modules/juce_core/text/juce_StringArray.cpp +++ b/modules/juce_core/text/juce_StringArray.cpp @@ -67,12 +67,10 @@ StringArray::StringArray (const wchar_t* const* initialStrings, int numberOfStri strings.addArray (initialStrings, numberOfStrings); } -#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS StringArray::StringArray (const std::initializer_list& stringList) { strings.addArray (stringList); } -#endif StringArray& StringArray::operator= (const StringArray& other) { diff --git a/modules/juce_core/text/juce_StringArray.h b/modules/juce_core/text/juce_StringArray.h index b45fd5c0f55c..51fdd2478bc2 100644 --- a/modules/juce_core/text/juce_StringArray.h +++ b/modules/juce_core/text/juce_StringArray.h @@ -51,9 +51,8 @@ class JUCE_API StringArray template StringArray (StringRef firstValue, OtherElements... otherValues) : strings (firstValue, otherValues...) {} - #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS + /** Creates an array containing a list of strings. */ StringArray (const std::initializer_list& strings); - #endif /** Creates an array from a raw array of strings. @param strings an array of strings to add diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index 2eb4e233f075..4999126f81d0 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -588,7 +588,6 @@ ValueTree::ValueTree (const Identifier& type) : object (new ValueTree::SharedOb jassert (type.toString().isNotEmpty()); // All objects must be given a sensible type name! } -#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS ValueTree::ValueTree (const Identifier& type, std::initializer_list> properties, std::initializer_list subTrees) @@ -600,7 +599,6 @@ ValueTree::ValueTree (const Identifier& type, for (auto& tree : subTrees) addChild (tree, -1, nullptr); } -#endif ValueTree::ValueTree (SharedObject* so) noexcept : object (so) { diff --git a/modules/juce_data_structures/values/juce_ValueTree.h b/modules/juce_data_structures/values/juce_ValueTree.h index 06505423dca7..70d0d3ffa394 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.h +++ b/modules/juce_data_structures/values/juce_ValueTree.h @@ -88,7 +88,6 @@ class JUCE_API ValueTree final */ explicit ValueTree (const Identifier& type); - #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS /** Creates a value tree from nested lists of properties and ValueTrees. This code, @@ -131,7 +130,6 @@ class JUCE_API ValueTree final ValueTree (const Identifier& type, std::initializer_list> properties, std::initializer_list subTrees = {}); - #endif /** Creates a reference to another ValueTree. */ ValueTree (const ValueTree&) noexcept; diff --git a/modules/juce_dsp/juce_dsp.cpp b/modules/juce_dsp/juce_dsp.cpp index 5b770dfc8c04..848e792990f7 100644 --- a/modules/juce_dsp/juce_dsp.cpp +++ b/modules/juce_dsp/juce_dsp.cpp @@ -35,9 +35,9 @@ #include "juce_dsp.h" -#if (! defined (JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT)) || (! defined (JUCE_HAS_CONSTEXPR)) +#if ! JUCE_HAS_CONSTEXPR #ifndef JUCE_DEMO_RUNNER - #error "juce_dsp module requires your compiler to have a newer version of the standard library" + #error "The juce_dsp module requires a compiler that supports constexpr" #endif #else diff --git a/modules/juce_dsp/juce_dsp.h b/modules/juce_dsp/juce_dsp.h index 3cdd6c231c73..bed712dc4b84 100644 --- a/modules/juce_dsp/juce_dsp.h +++ b/modules/juce_dsp/juce_dsp.h @@ -59,9 +59,9 @@ #include #include -#if (! defined (JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT)) || (! defined (JUCE_HAS_CONSTEXPR)) +#if ! JUCE_HAS_CONSTEXPR #ifndef JUCE_DEMO_RUNNER - #error "juce_dsp module requires your compiler to have a newer version of the standard library" + #error "The juce_dsp module requires a compiler that supports constexpr" #endif #else diff --git a/modules/juce_gui_basics/juce_gui_basics.cpp b/modules/juce_gui_basics/juce_gui_basics.cpp index b8148e76f602..4c6dc5b315b5 100644 --- a/modules/juce_gui_basics/juce_gui_basics.cpp +++ b/modules/juce_gui_basics/juce_gui_basics.cpp @@ -267,15 +267,12 @@ namespace juce #include "misc/juce_DropShadower.cpp" #include "misc/juce_JUCESplashScreen.cpp" -// these classes are C++11-only -#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS - #include "layout/juce_FlexBox.cpp" - #if JUCE_HAS_CONSTEXPR - #include "layout/juce_GridItem.cpp" - #include "layout/juce_Grid.cpp" - #if JUCE_UNIT_TESTS - #include "layout/juce_GridUnitTests.cpp" - #endif +#include "layout/juce_FlexBox.cpp" +#if JUCE_HAS_CONSTEXPR + #include "layout/juce_GridItem.cpp" + #include "layout/juce_Grid.cpp" + #if JUCE_UNIT_TESTS + #include "layout/juce_GridUnitTests.cpp" #endif #endif diff --git a/modules/juce_gui_basics/juce_gui_basics.h b/modules/juce_gui_basics/juce_gui_basics.h index 7103564f5c80..d1956acff634 100644 --- a/modules/juce_gui_basics/juce_gui_basics.h +++ b/modules/juce_gui_basics/juce_gui_basics.h @@ -149,12 +149,10 @@ namespace juce class ApplicationCommandManagerListener; class DrawableButton; - #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS class FlexBox; #if JUCE_HAS_CONSTEXPR class Grid; #endif - #endif } #include "mouse/juce_MouseCursor.h" @@ -294,13 +292,10 @@ namespace juce #include "native/juce_linux_X11.h" #endif -// these classes are C++11-only -#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS - #include "layout/juce_FlexItem.h" - #include "layout/juce_FlexBox.h" +#include "layout/juce_FlexItem.h" +#include "layout/juce_FlexBox.h" - #if JUCE_HAS_CONSTEXPR - #include "layout/juce_GridItem.h" - #include "layout/juce_Grid.h" - #endif +#if JUCE_HAS_CONSTEXPR + #include "layout/juce_GridItem.h" + #include "layout/juce_Grid.h" #endif diff --git a/modules/juce_osc/juce_osc.cpp b/modules/juce_osc/juce_osc.cpp index 3a7ebf9cd012..6e026de4dfeb 100644 --- a/modules/juce_osc/juce_osc.cpp +++ b/modules/juce_osc/juce_osc.cpp @@ -35,12 +35,6 @@ #include "juce_osc.h" -#ifndef JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT - #ifndef JUCE_DEMO_RUNNER - #error "juce_osc module requires your compiler to have a newer version of the standard library" - #endif -#else - #include "osc/juce_OSCTypes.cpp" #include "osc/juce_OSCTimeTag.cpp" #include "osc/juce_OSCArgument.cpp" @@ -49,5 +43,3 @@ #include "osc/juce_OSCBundle.cpp" #include "osc/juce_OSCReceiver.cpp" #include "osc/juce_OSCSender.cpp" - -#endif diff --git a/modules/juce_osc/juce_osc.h b/modules/juce_osc/juce_osc.h index 3acfe178a6b0..894d09303990 100644 --- a/modules/juce_osc/juce_osc.h +++ b/modules/juce_osc/juce_osc.h @@ -54,12 +54,6 @@ #include #include -#ifndef JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT - #ifndef JUCE_DEMO_RUNNER - #error "juce_osc module requires your compiler to have a newer version of the standard library" - #endif -#else - //============================================================================== #include "osc/juce_OSCTypes.h" #include "osc/juce_OSCTimeTag.h" @@ -69,5 +63,3 @@ #include "osc/juce_OSCBundle.h" #include "osc/juce_OSCReceiver.h" #include "osc/juce_OSCSender.h" - -#endif