From 0e00e8394485fa26b2e32ddc9a260cce8ebc041a Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Fri, 28 Jun 2019 15:34:16 +0100 Subject: [PATCH] Removed some `extern "C"` declarations from libpng --- .../image_formats/juce_PNGLoader.cpp | 4 ++-- .../image_formats/pnglib/libpng_readme.txt | 4 +++- modules/juce_graphics/image_formats/pnglib/png.h | 16 +++++++++------- .../juce_graphics/image_formats/pnglib/pngpriv.h | 16 +++++++++------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/modules/juce_graphics/image_formats/juce_PNGLoader.cpp b/modules/juce_graphics/image_formats/juce_PNGLoader.cpp index 66e4167f37..8afd94f287 100644 --- a/modules/juce_graphics/image_formats/juce_PNGLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_PNGLoader.cpp @@ -271,8 +271,8 @@ namespace pnglibNamespace #define PNG_sCAL_PRECISION 5 #define PNG_sRGB_PROFILE_CHECKS 2 - #define PNG_LINKAGE_API inline - #define PNG_LINKAGE_FUNCTION inline + #define PNG_LINKAGE_API + #define PNG_LINKAGE_FUNCTION #define PNG_ARM_NEON_OPT 0 diff --git a/modules/juce_graphics/image_formats/pnglib/libpng_readme.txt b/modules/juce_graphics/image_formats/pnglib/libpng_readme.txt index 75a4595a21..156a800828 100644 --- a/modules/juce_graphics/image_formats/pnglib/libpng_readme.txt +++ b/modules/juce_graphics/image_formats/pnglib/libpng_readme.txt @@ -1,2 +1,4 @@ - These files are from the libpng library - http://www.libpng.org/ + +We have removed all `extern "C"` from the library to prevent symbol collision +with projects that use their own version of libpng. diff --git a/modules/juce_graphics/image_formats/pnglib/png.h b/modules/juce_graphics/image_formats/pnglib/png.h index 139eb0dc0f..9fe598be30 100644 --- a/modules/juce_graphics/image_formats/pnglib/png.h +++ b/modules/juce_graphics/image_formats/pnglib/png.h @@ -363,10 +363,11 @@ #ifndef PNG_VERSION_INFO_ONLY -/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +// JUCE modification +///* Inhibit C++ name-mangling for libpng functions but not for system calls. */ +//#ifdef __cplusplus +//extern "C" { +//#endif /* __cplusplus */ /* Version information for C files, stored in png.c. This had better match * the version above. @@ -3238,9 +3239,10 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, PNG_EXPORT_LAST_ORDINAL(249); #endif -#ifdef __cplusplus -} -#endif +// JUCE modification +//#ifdef __cplusplus +//} +//#endif #endif /* PNG_VERSION_INFO_ONLY */ /* Do not put anything past this line */ diff --git a/modules/juce_graphics/image_formats/pnglib/pngpriv.h b/modules/juce_graphics/image_formats/pnglib/pngpriv.h index 583c26f9bd..7d6605515c 100644 --- a/modules/juce_graphics/image_formats/pnglib/pngpriv.h +++ b/modules/juce_graphics/image_formats/pnglib/pngpriv.h @@ -958,10 +958,11 @@ PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]); #endif /* SIMPLIFIED_READ/WRITE */ -/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +// JUCE modification +///* Inhibit C++ name-mangling for libpng functions but not for system calls. */ +//#ifdef __cplusplus +//extern "C" { +//#endif /* __cplusplus */ /* Internal functions; these are not exported from a DLL however because they * are used within several of the C source files they have to be C extern. @@ -2144,9 +2145,10 @@ PNG_INTERNAL_FUNCTION(int, #include "pngdebug.h" -#ifdef __cplusplus -} -#endif +// JUCE modification +//#ifdef __cplusplus +//} +//#endif #endif /* PNG_VERSION_INFO_ONLY */ #endif /* PNGPRIV_H */