diff --git a/examples/Plugins/SamplerPluginDemo.h b/examples/Plugins/SamplerPluginDemo.h index 38e1f47a1f..4d677d8764 100644 --- a/examples/Plugins/SamplerPluginDemo.h +++ b/examples/Plugins/SamplerPluginDemo.h @@ -2006,8 +2006,7 @@ private: loopKindLabel { {}, "Looping Mode" }; - FileChooser fileChooser { "Select a file to load...", - File::nonexistent, + FileChooser fileChooser { "Select a file to load...", File(), dataModel.getAudioFormatManager().getWildcardForAllFormats() }; UndoManager* undoManager; diff --git a/modules/juce_core/containers/juce_Variant.cpp b/modules/juce_core/containers/juce_Variant.cpp index e3b307ff9b..43b8180ddc 100644 --- a/modules/juce_core/containers/juce_Variant.cpp +++ b/modules/juce_core/containers/juce_Variant.cpp @@ -435,9 +435,7 @@ var::var() noexcept : type (&VariantType_Void::instance) {} var::var (const VariantType& t) noexcept : type (&t) {} var::~var() noexcept { type->cleanUp (value); } -#if JUCE_ALLOW_STATIC_NULL_VARIABLES -const var var::null; -#endif +JUCE_DECLARE_DEPRECATED_STATIC (const var var::null); //============================================================================== var::var (const var& valueToCopy) : type (valueToCopy.type) diff --git a/modules/juce_core/containers/juce_Variant.h b/modules/juce_core/containers/juce_Variant.h index ca5d8c73d6..975c6781f0 100644 --- a/modules/juce_core/containers/juce_Variant.h +++ b/modules/juce_core/containers/juce_Variant.h @@ -274,17 +274,15 @@ public: */ static var readFromStream (InputStream& input); - #if JUCE_ALLOW_STATIC_NULL_VARIABLES - /** This was a static empty var object, but is now deprecated as it's too easy to accidentally - use it indirectly during a static constructor, leading to hard-to-find order-of-initialisation - problems. - @deprecated If you need a default-constructed var, just use var() or {}. - The only time you might miss having var::null available might be if you need to return an - empty var from a function by reference, but if you need to do that, it's easy enough to use - a function-local static var and return that, avoiding any order-of-initialisation issues. + /* This was a static empty var object, but is now deprecated as it's too easy to accidentally + use it indirectly during a static constructor, leading to hard-to-find order-of-initialisation + problems. + @deprecated If you need a default-constructed var, just use var() or {}. + The only time you might miss having var::null available might be if you need to return an + empty var from a function by reference, but if you need to do that, it's easy enough to use + a function-local static var and return that, avoiding any order-of-initialisation issues. */ - static const var null; - #endif + JUCE_DEPRECATED_STATIC (static const var null); private: //============================================================================== diff --git a/modules/juce_core/files/juce_File.cpp b/modules/juce_core/files/juce_File.cpp index 6f3eb0b1ec..1bf3258964 100644 --- a/modules/juce_core/files/juce_File.cpp +++ b/modules/juce_core/files/juce_File.cpp @@ -63,9 +63,7 @@ File& File::operator= (File&& other) noexcept return *this; } -#if JUCE_ALLOW_STATIC_NULL_VARIABLES -const File File::nonexistent; -#endif +JUCE_DECLARE_DEPRECATED_STATIC (const File File::nonexistent); //============================================================================== static String removeEllipsis (const String& path) diff --git a/modules/juce_core/files/juce_File.h b/modules/juce_core/files/juce_File.h index 7b55ca442c..5c11921964 100644 --- a/modules/juce_core/files/juce_File.h +++ b/modules/juce_core/files/juce_File.h @@ -1048,21 +1048,14 @@ public: bool foldersFirst; }; - #if (! defined(DOXYGEN)) && (! defined (JUCE_GCC)) - // Deprecated: use File::getSeparatorChar() and File::getSeparatorString() instead! - JUCE_DEPRECATED (static const juce_wchar separator); - JUCE_DEPRECATED (static const StringRef separatorString); - #endif - - //============================================================================== - #if JUCE_ALLOW_STATIC_NULL_VARIABLES - /** This was a static empty File object, but is now deprecated as it's too easy to accidentally - use it indirectly during a static constructor, leading to hard-to-find order-of-initialisation - problems. - @deprecated If you need a default-constructed File object, just use File() or {}. - */ - static const File nonexistent; - #endif + /* These static objects are deprecated because it's too easy to accidentally use them indirectly + during a static constructor, which leads to very obscure order-of-initialisation bugs. + Use File::getSeparatorChar() and File::getSeparatorString(), and instead of File::nonexistent, + just use File() or {}. + */ + JUCE_DEPRECATED_STATIC (static const juce_wchar separator); + JUCE_DEPRECATED_STATIC (static const StringRef separatorString); + JUCE_DEPRECATED_STATIC (static const File nonexistent); private: //============================================================================== diff --git a/modules/juce_core/system/juce_PlatformDefs.h b/modules/juce_core/system/juce_PlatformDefs.h index 2c4940e24e..0666bccf3e 100644 --- a/modules/juce_core/system/juce_PlatformDefs.h +++ b/modules/juce_core/system/juce_PlatformDefs.h @@ -273,6 +273,28 @@ namespace juce #define JUCE_DEPRECATED_WITH_BODY(functionDef, body) functionDef body #endif +#if JUCE_ALLOW_STATIC_NULL_VARIABLES + #if ! (defined (DOXYGEN) || defined (JUCE_GCC) || (JUCE_MSVC && _MSC_VER <= 1900)) + #define JUCE_DEPRECATED_STATIC(valueDef) JUCE_DEPRECATED (valueDef) + + #if JUCE_MSVC + #define JUCE_DECLARE_DEPRECATED_STATIC(valueDef) \ + __pragma(warning(push)) \ + __pragma(warning(disable:4996)) \ + valueDef \ + __pragma(warning(pop)) + #else + #define JUCE_DECLARE_DEPRECATED_STATIC(valueDef) valueDef + #endif + #else + #define JUCE_DEPRECATED_STATIC(valueDef) valueDef + #define JUCE_DECLARE_DEPRECATED_STATIC(valueDef) valueDef + #endif +#else + #define JUCE_DEPRECATED_STATIC(valueDef) + #define JUCE_DECLARE_DEPRECATED_STATIC(valueDef) +#endif + //============================================================================== #if JUCE_ANDROID && ! DOXYGEN #define JUCE_MODAL_LOOPS_PERMITTED 0 diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index ce93d7a9ff..88d530aec5 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -235,9 +235,7 @@ private: } }; -#if JUCE_ALLOW_STATIC_NULL_VARIABLES -const String String::empty; -#endif +JUCE_DECLARE_DEPRECATED_STATIC (const String String::empty); //============================================================================== String::String() noexcept : text (&(emptyString.text)) diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index ae5937ed06..a778be1ce5 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -1239,8 +1239,7 @@ public: int getReferenceCount() const noexcept; //============================================================================== - #if JUCE_ALLOW_STATIC_NULL_VARIABLES - /** This was a static empty string object, but is now deprecated as it's too easy to accidentally + /* This was a static empty string object, but is now deprecated as it's too easy to accidentally use it indirectly during a static constructor, leading to hard-to-find order-of-initialisation problems. @deprecated If you need an empty String object, just use String() or {}. @@ -1248,8 +1247,7 @@ public: empty string from a function by reference, but if you need to do that, it's easy enough to use a function-local static String object and return that, avoiding any order-of-initialisation issues. */ - static const String empty; - #endif + JUCE_DEPRECATED_STATIC (static const String empty); private: //============================================================================== diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index 803e3bf277..e40410d93f 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -579,9 +579,7 @@ ValueTree::ValueTree() noexcept { } -#if JUCE_ALLOW_STATIC_NULL_VARIABLES -const ValueTree ValueTree::invalid; -#endif +JUCE_DECLARE_DEPRECATED_STATIC (const ValueTree ValueTree::invalid); ValueTree::ValueTree (const Identifier& type) : object (new ValueTree::SharedObject (type)) { diff --git a/modules/juce_data_structures/values/juce_ValueTree.h b/modules/juce_data_structures/values/juce_ValueTree.h index 70d0d3ffa3..b1cffbdae8 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.h +++ b/modules/juce_data_structures/values/juce_ValueTree.h @@ -589,12 +589,10 @@ public: */ int getReferenceCount() const noexcept; - #if JUCE_ALLOW_STATIC_NULL_VARIABLES - /** An invalid ValueTree that can be used if you need to return one as an error condition, etc. + /* An invalid ValueTree that can be used if you need to return one as an error condition, etc. @deprecated If you need an empty ValueTree object, just use ValueTree() or {}. */ - static const ValueTree invalid; - #endif + JUCE_DEPRECATED_STATIC (static const ValueTree invalid); private: //============================================================================== diff --git a/modules/juce_graphics/geometry/juce_AffineTransform.cpp b/modules/juce_graphics/geometry/juce_AffineTransform.cpp index 6a2574aa89..e1c6b3fd55 100644 --- a/modules/juce_graphics/geometry/juce_AffineTransform.cpp +++ b/modules/juce_graphics/geometry/juce_AffineTransform.cpp @@ -84,9 +84,7 @@ bool AffineTransform::isIdentity() const noexcept && mat11 == 1.0f; } -#if JUCE_ALLOW_STATIC_NULL_VARIABLES -const AffineTransform AffineTransform::identity; -#endif +JUCE_DECLARE_DEPRECATED_STATIC (const AffineTransform AffineTransform::identity); //============================================================================== AffineTransform AffineTransform::followedBy (const AffineTransform& other) const noexcept diff --git a/modules/juce_graphics/geometry/juce_AffineTransform.h b/modules/juce_graphics/geometry/juce_AffineTransform.h index fbf12291bc..e7461bc21f 100644 --- a/modules/juce_graphics/geometry/juce_AffineTransform.h +++ b/modules/juce_graphics/geometry/juce_AffineTransform.h @@ -270,12 +270,10 @@ public: */ float getScaleFactor() const noexcept; - #if JUCE_ALLOW_STATIC_NULL_VARIABLES - /** A ready-to-use identity transform - now depracated. - @deprecated If you need an identity transform, just use AffineTransform() or {}. + /* A ready-to-use identity transform - now depracated. + @deprecated If you need an identity transform, just use AffineTransform() or {}. */ - static const AffineTransform identity; - #endif + JUCE_DEPRECATED_STATIC (static const AffineTransform identity); //============================================================================== /* The transform matrix is: diff --git a/modules/juce_graphics/images/juce_Image.cpp b/modules/juce_graphics/images/juce_Image.cpp index 51d828714e..6b478349b2 100644 --- a/modules/juce_graphics/images/juce_Image.cpp +++ b/modules/juce_graphics/images/juce_Image.cpp @@ -262,9 +262,7 @@ Image::~Image() { } -#if JUCE_ALLOW_STATIC_NULL_VARIABLES -const Image Image::null; -#endif +JUCE_DECLARE_DEPRECATED_STATIC (const Image Image::null); int Image::getReferenceCount() const noexcept { return image == nullptr ? 0 : image->getSharedCount(); } int Image::getWidth() const noexcept { return image == nullptr ? 0 : image->width; } diff --git a/modules/juce_graphics/images/juce_Image.h b/modules/juce_graphics/images/juce_Image.h index a35440979c..74de5addf5 100644 --- a/modules/juce_graphics/images/juce_Image.h +++ b/modules/juce_graphics/images/juce_Image.h @@ -414,12 +414,10 @@ public: /** @internal */ explicit Image (ImagePixelData*) noexcept; - #if JUCE_ALLOW_STATIC_NULL_VARIABLES - /** A null Image object that can be used when you need to return an invalid image. + /* A null Image object that can be used when you need to return an invalid image. @deprecated If you need a default-constructed var, just use Image() or {}. */ - static const Image null; - #endif + JUCE_DEPRECATED_STATIC (static const Image null); private: //==============================================================================