From cf39ad4b0204cd3e3676a259fef04ac268e72bdb Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 26 May 2016 11:50:04 +0100 Subject: [PATCH] Fix multiple compile errors on older gcc versions --- examples/Demo/Source/MainWindow.cpp | 16 ++--- examples/Demo/Source/MainWindow.h | 3 + .../buffers/juce_FloatVectorOperations.cpp | 17 +++-- .../juce_audio_formats/codecs/flac/alloc.h | 13 ++-- .../juce_audio_formats/codecs/flac/assert.h | 5 +- .../juce_audio_formats/codecs/flac/callback.h | 5 +- .../juce_audio_formats/codecs/flac/compat.h | 33 ---------- .../juce_audio_formats/codecs/flac/endswap.h | 4 +- .../juce_audio_formats/codecs/flac/metadata.h | 1 - .../codecs/flac/stream_decoder.h | 1 - .../codecs/flac/stream_encoder.h | 1 - .../codecs/flac/win_utf8_io.h | 5 -- .../codecs/juce_FlacAudioFormat.cpp | 62 ++++++++++++++++++- .../box2d/Dynamics/Contacts/b2Contact.h | 2 +- .../juce_core/system/juce_CompilerSupport.h | 2 +- 15 files changed, 104 insertions(+), 66 deletions(-) diff --git a/examples/Demo/Source/MainWindow.cpp b/examples/Demo/Source/MainWindow.cpp index 2426148048..ea2e6aa638 100644 --- a/examples/Demo/Source/MainWindow.cpp +++ b/examples/Demo/Source/MainWindow.cpp @@ -22,6 +22,7 @@ ============================================================================== */ +#include #include "JuceDemoHeader.h" //============================================================================== @@ -558,19 +559,18 @@ AudioDeviceManager& MainAppWindow::getSharedAudioDeviceManager() if (sharedAudioDeviceManager == nullptr) { sharedAudioDeviceManager = new AudioDeviceManager(); - - RuntimePermissions::request ( - RuntimePermissions::recordAudio, - [] (bool wasGranted) { - int numInputChannels = wasGranted ? 2 : 0; - sharedAudioDeviceManager->initialise (numInputChannels, 2, nullptr, true, String(), nullptr); - } - ); + RuntimePermissions::request (RuntimePermissions::recordAudio, runtimPermissionsCallback); } return *sharedAudioDeviceManager; } +void MainAppWindow::runtimPermissionsCallback (bool wasGranted) +{ + int numInputChannels = wasGranted ? 2 : 0; + sharedAudioDeviceManager->initialise (numInputChannels, 2, nullptr, true, String(), nullptr); +} + MainAppWindow* MainAppWindow::getMainAppWindow() { for (int i = TopLevelWindow::getNumTopLevelWindows(); --i >= 0;) diff --git a/examples/Demo/Source/MainWindow.h b/examples/Demo/Source/MainWindow.h index e1f5610dde..5baa678f3c 100644 --- a/examples/Demo/Source/MainWindow.h +++ b/examples/Demo/Source/MainWindow.h @@ -93,6 +93,9 @@ public: }; private: + + static void runtimPermissionsCallback (bool wasGranted); + ScopedPointer contentComponent; ScopedPointer taskbarIcon; ScopedPointer currentBubbleMessage; diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp index 0f91bc2426..0d60e3e87c 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp @@ -204,10 +204,11 @@ namespace FloatVectorHelpers typedef float Type; typedef float32x4_t ParallelType; typedef uint32x4_t IntegerType; + union signMaskUnion { ParallelType f; IntegerType i; }; enum { numParallel = 4 }; - static forcedinline IntegerType toint (ParallelType v) noexcept { union { ParallelType f; IntegerType i; } u; u.f = v; return u.i; } - static forcedinline ParallelType toflt (IntegerType v) noexcept { union { ParallelType f; IntegerType i; } u; u.i = v; return u.f; } + static forcedinline IntegerType toint (ParallelType v) noexcept { signMaskUnion u; u.f = v; return u.i; } + static forcedinline ParallelType toflt (IntegerType v) noexcept { signMaskUnion u; u.i = v; return u.f; } static forcedinline ParallelType load1 (Type v) noexcept { return vld1q_dup_f32 (&v); } static forcedinline ParallelType loadA (const Type* v) noexcept { return vld1q_f32 (v); } @@ -235,10 +236,11 @@ namespace FloatVectorHelpers typedef double Type; typedef double ParallelType; typedef uint64 IntegerType; + union signMaskUnion { ParallelType f; IntegerType i; }; enum { numParallel = 1 }; - static forcedinline IntegerType toint (ParallelType v) noexcept { union { ParallelType f; IntegerType i; } u; u.f = v; return u.i; } - static forcedinline ParallelType toflt (IntegerType v) noexcept { union { ParallelType f; IntegerType i; } u; u.i = v; return u.f; } + static forcedinline IntegerType toint (ParallelType v) noexcept { signMaskUnion u; u.f = v; return u.i; } + static forcedinline ParallelType toflt (IntegerType v) noexcept { signMaskUnion u; u.i = v; return u.f; } static forcedinline ParallelType load1 (Type v) noexcept { return v; } static forcedinline ParallelType loadA (const Type* v) noexcept { return *v; } @@ -346,6 +348,9 @@ namespace FloatVectorHelpers #define JUCE_LOAD_SRC1_SRC2_DEST(src1Load, src2Load, dstLoad) const Mode::ParallelType d = dstLoad (dest), s1 = src1Load (src1), s2 = src2Load (src2); #define JUCE_LOAD_SRC_DEST(srcLoad, dstLoad) const Mode::ParallelType d = dstLoad (dest), s = srcLoad (src); + union signMask32 { float f; uint32 i; }; + union signMask64 { double d; uint64 i; }; + #if JUCE_USE_SSE_INTRINSICS || JUCE_USE_ARM_NEON template struct ModeType { typedef BasicOps32 Mode; }; template<> struct ModeType<8> { typedef BasicOps64 Mode; }; @@ -806,7 +811,7 @@ void FloatVectorOperations::abs (float* dest, const float* src, int num) noexcep #if JUCE_USE_VDSP_FRAMEWORK vDSP_vabs ((float*) src, 1, dest, 1, (vDSP_Length) num); #else - union { float f; uint32 i; } signMask; + FloatVectorHelpers::signMask32 signMask; signMask.i = 0x7fffffffUL; JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = fabsf (src[i]), Mode::bit_and (s, mask), JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST, @@ -821,7 +826,7 @@ void FloatVectorOperations::abs (double* dest, const double* src, int num) noexc #if JUCE_USE_VDSP_FRAMEWORK vDSP_vabsD ((double*) src, 1, dest, 1, (vDSP_Length) num); #else - union {double d; uint64 i;} signMask; + FloatVectorHelpers::signMask64 signMask; signMask.i = 0x7fffffffffffffffULL; JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = fabs (src[i]), Mode::bit_and (s, mask), diff --git a/modules/juce_audio_formats/codecs/flac/alloc.h b/modules/juce_audio_formats/codecs/flac/alloc.h index 3aab81c271..04d26a8cc3 100644 --- a/modules/juce_audio_formats/codecs/flac/alloc.h +++ b/modules/juce_audio_formats/codecs/flac/alloc.h @@ -41,11 +41,14 @@ * before #including this file, otherwise SIZE_MAX might not be defined */ -#include /* for SIZE_MAX */ -#if HAVE_STDINT_H -#include /* for SIZE_MAX in case limits.h didn't get it */ -#endif -#include /* for size_t, malloc(), etc */ +// JUCE: removed as JUCE already includes standard headers and including +// these in FlacNamespace will cause problems + +//#include /* for SIZE_MAX */ +//#if HAVE_STDINT_H +//#include /* for SIZE_MAX in case limits.h didn't get it */ +//#endif +//#include /* for size_t, malloc(), etc */ #include "compat.h" #ifndef SIZE_MAX diff --git a/modules/juce_audio_formats/codecs/flac/assert.h b/modules/juce_audio_formats/codecs/flac/assert.h index f02aeac100..ec5f4371be 100644 --- a/modules/juce_audio_formats/codecs/flac/assert.h +++ b/modules/juce_audio_formats/codecs/flac/assert.h @@ -35,7 +35,10 @@ /* we need this since some compilers (like MSVC) leave assert()s on release code (and we don't want to use their ASSERT) */ #ifdef DEBUG -#include +// JUCE: removed as JUCE already includes standard headers and including +// these in FlacNamespace will cause problems + +//#include #define FLAC__ASSERT(x) assert(x) #define FLAC__ASSERT_DECLARATION(x) x #else diff --git a/modules/juce_audio_formats/codecs/flac/callback.h b/modules/juce_audio_formats/codecs/flac/callback.h index 9928843bb3..851add9ac4 100644 --- a/modules/juce_audio_formats/codecs/flac/callback.h +++ b/modules/juce_audio_formats/codecs/flac/callback.h @@ -34,7 +34,10 @@ #define FLAC__CALLBACK_H #include "ordinals.h" -#include /* for size_t */ + +// JUCE: removed as JUCE already includes this and including stdlib +// in FlacNamespace will cause problems +//#include /** \file include/FLAC/callback.h * diff --git a/modules/juce_audio_formats/codecs/flac/compat.h b/modules/juce_audio_formats/codecs/flac/compat.h index a3dc7c7b9f..543f49e83a 100644 --- a/modules/juce_audio_formats/codecs/flac/compat.h +++ b/modules/juce_audio_formats/codecs/flac/compat.h @@ -39,15 +39,7 @@ #ifndef FLAC__SHARE__COMPAT_H #define FLAC__SHARE__COMPAT_H -#if defined _WIN32 && !defined __CYGWIN__ -/* where MSVC puts unlink() */ -# include -#else -# include -#endif - #if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ -#include /* for off_t */ #define FLAC__off_t __int64 /* use this instead of off_t to fix the 2 GB limit */ #if !defined __MINGW32__ #define fseeko _fseeki64 @@ -62,11 +54,6 @@ #define FLAC__off_t off_t #endif -#if HAVE_INTTYPES_H -#define __STDC_FORMAT_MACROS -#include -#endif - #if defined(_MSC_VER) #define strtoll _strtoi64 #define strtoull _strtoui64 @@ -95,33 +82,13 @@ #define FLAC__STRNCASECMP strncasecmp #endif -#if defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ || defined __EMX__ -#include /* for _setmode(), chmod() */ -#include /* for _O_BINARY */ -#else -#include /* for chown(), unlink() */ -#endif - -#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ -#if defined __BORLANDC__ -#include /* for utime() */ -#else -#include /* for utime() */ -#endif -#else -#include /* some flavors of BSD (like OS X) require this to get time_t */ -#include /* for utime() */ -#endif - #if defined _MSC_VER # if _MSC_VER >= 1600 /* Visual Studio 2010 has decent C99 support */ -# include # define PRIu64 "llu" # define PRId64 "lld" # define PRIx64 "llx" # else -# include # ifndef UINT32_MAX # define UINT32_MAX _UI32_MAX # endif diff --git a/modules/juce_audio_formats/codecs/flac/endswap.h b/modules/juce_audio_formats/codecs/flac/endswap.h index b2a7e85506..aa81dadf37 100644 --- a/modules/juce_audio_formats/codecs/flac/endswap.h +++ b/modules/juce_audio_formats/codecs/flac/endswap.h @@ -51,7 +51,9 @@ static inline unsigned short __builtin_bswap16(unsigned short a) #elif defined HAVE_BYTESWAP_H /* Linux */ -#include +// JUCE: removed as JUCE already includes standard headers and including +// these in FlacNamespace will cause problems +//#include #define ENDSWAP_16(x) (bswap_16 (x)) #define ENDSWAP_32(x) (bswap_32 (x)) diff --git a/modules/juce_audio_formats/codecs/flac/metadata.h b/modules/juce_audio_formats/codecs/flac/metadata.h index 02cfc32273..42e2aa5752 100644 --- a/modules/juce_audio_formats/codecs/flac/metadata.h +++ b/modules/juce_audio_formats/codecs/flac/metadata.h @@ -33,7 +33,6 @@ #ifndef FLAC__METADATA_H #define FLAC__METADATA_H -#include /* for off_t */ #include "export.h" #include "callback.h" #include "format.h" diff --git a/modules/juce_audio_formats/codecs/flac/stream_decoder.h b/modules/juce_audio_formats/codecs/flac/stream_decoder.h index 50cd7544ba..e0176dbbc2 100644 --- a/modules/juce_audio_formats/codecs/flac/stream_decoder.h +++ b/modules/juce_audio_formats/codecs/flac/stream_decoder.h @@ -33,7 +33,6 @@ #ifndef FLAC__STREAM_DECODER_H #define FLAC__STREAM_DECODER_H -#include /* for FILE */ #include "export.h" #include "format.h" diff --git a/modules/juce_audio_formats/codecs/flac/stream_encoder.h b/modules/juce_audio_formats/codecs/flac/stream_encoder.h index 646efb799c..b28e5a28f6 100644 --- a/modules/juce_audio_formats/codecs/flac/stream_encoder.h +++ b/modules/juce_audio_formats/codecs/flac/stream_encoder.h @@ -33,7 +33,6 @@ #ifndef FLAC__STREAM_ENCODER_H #define FLAC__STREAM_ENCODER_H -#include /* for FILE */ #include "export.h" #include "format.h" #include "stream_decoder.h" diff --git a/modules/juce_audio_formats/codecs/flac/win_utf8_io.h b/modules/juce_audio_formats/codecs/flac/win_utf8_io.h index 8834e10e02..6333eef24d 100644 --- a/modules/juce_audio_formats/codecs/flac/win_utf8_io.h +++ b/modules/juce_audio_formats/codecs/flac/win_utf8_io.h @@ -38,11 +38,6 @@ extern "C" { #endif -#include -#include -#include -#include - int get_utf8_argv(int *argc, char ***argv); int printf_utf8(const char *format, ...); diff --git a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp index 2afebbed33..dd3d52545e 100644 --- a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp @@ -24,6 +24,66 @@ #if JUCE_USE_FLAC +} + +#if defined _WIN32 && !defined __CYGWIN__ + #include +#else + #include +#endif + +#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ + #include /* for off_t */ +#endif + +#if HAVE_INTTYPES_H + #define __STDC_FORMAT_MACROS + #include +#endif + +#if defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ || defined __EMX__ + #include /* for _setmode(), chmod() */ + #include /* for _O_BINARY */ +#else + #include /* for chown(), unlink() */ +#endif + +#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ + #if defined __BORLANDC__ + #include /* for utime() */ + #else + #include /* for utime() */ + #endif +#else + #include /* some flavors of BSD (like OS X) require this to get time_t */ + #include /* for utime() */ +#endif + +#if defined _MSC_VER + #if _MSC_VER >= 1600 + #include + #else + #include + #endif +#endif + +#ifdef _WIN32 + #include + #include + #include + #include +#endif + +#ifdef DEBUG + #include +#endif + +#include +#include + +namespace juce +{ + namespace FlacNamespace { #if JUCE_INCLUDE_FLAC_CODE || ! defined (JUCE_INCLUDE_FLAC_CODE) @@ -62,7 +122,7 @@ namespace FlacNamespace #define FLAC__HAS_X86INTRIN 1 #endif - #undef __STDC_LIMIT_MACROS +#undef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #define flac_max jmax #define flac_min jmin diff --git a/modules/juce_box2d/box2d/Dynamics/Contacts/b2Contact.h b/modules/juce_box2d/box2d/Dynamics/Contacts/b2Contact.h index 00f209aee5..a5bde5b59c 100644 --- a/modules/juce_box2d/box2d/Dynamics/Contacts/b2Contact.h +++ b/modules/juce_box2d/box2d/Dynamics/Contacts/b2Contact.h @@ -239,7 +239,7 @@ inline void b2Contact::SetEnabled(bool flag) } else { - m_flags &= ~e_enabledFlag; + m_flags &= ~((unsigned int) e_enabledFlag); } } diff --git a/modules/juce_core/system/juce_CompilerSupport.h b/modules/juce_core/system/juce_CompilerSupport.h index 9b903c8e1d..5169a37336 100644 --- a/modules/juce_core/system/juce_CompilerSupport.h +++ b/modules/juce_core/system/juce_CompilerSupport.h @@ -98,7 +98,7 @@ #define JUCE_COMPILER_SUPPORTS_STATIC_ASSERT 1 #endif - #ifndef JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL + #if __has_feature (cxx_override_control) && (! defined (JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL)) #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 #endif