From eb6fa3d980356255b4dbeef92828b027e01da961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Mon, 21 Dec 2015 14:38:59 +0200 Subject: [PATCH] Fix exporting functions in library. Rewrites definition of macro KVZ_PUBLIC in kvazaar.h so that KVZ_STATIC_LIB need not be defined when building a static library. --- src/kvazaar.h | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/kvazaar.h b/src/kvazaar.h index 75bac24d..fa8f16fd 100644 --- a/src/kvazaar.h +++ b/src/kvazaar.h @@ -34,26 +34,30 @@ extern "C" { #endif -#if defined(KVZ_STATIC_LIB) && defined(PIC) - #undef KVZ_STATIC_LIB -#endif - -#if defined(KVZ_STATIC_LIB) - // Using or building kvazaar as a static library. - #define KVZ_PUBLIC -#elif defined(_WIN32) || defined(__CYGWIN__) - #ifdef KVZ_DLL_EXPORTS - // Building kvazaar on windows. +#if defined(KVZ_DLL_EXPORTS) + #if !defined(PIC) + // Building static kvazaar library. + #define KVZ_PUBLIC + #elif defined(_WIN32) || defined(__CYGWIN__) + // Building kvazaar DLL on Windows. #define KVZ_PUBLIC __declspec(dllexport) + #elif defined(__GNUC__) + // Building kvazaar shared library with GCC. + #define KVZ_PUBLIC __attribute__ ((visibility ("default"))) #else - // Using kvazaar as a DLL on windows. - #define KVZ_PUBLIC __declspec(dllimport) + #define KVZ_PUBLIC #endif -#elif defined(__GNUC__) - // Using GCC and not on windows. - #define KVZ_PUBLIC __attribute__ ((visibility ("default"))) #else - #define KVZ_PUBLIC + #if defined(KVZ_STATIC_LIB) + // Using static kvazaar library. + #define KVZ_PUBLIC + #elif defined(_WIN32) || defined(__CYGWIN__) + // Using kvazaar DLL on Windows. + #define KVZ_PUBLIC __declspec(dllimport) + #else + // Using kvazaar shared library and not on Windows. + #define KVZ_PUBLIC + #endif #endif /**