summaryrefslogtreecommitdiff
path: root/cpp/include
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2015-05-05 19:23:45 -0400
committerBernard Normier <bernard@zeroc.com>2015-05-05 19:23:45 -0400
commita5bd24845a2720d57a66d81effc59423d723c87c (patch)
tree76faa296700b0993deb3aa97323abc904188a681 /cpp/include
parentminor fixes for purify (diff)
downloadice-a5bd24845a2720d57a66d81effc59423d723c87c.tar.bz2
ice-a5bd24845a2720d57a66d81effc59423d723c87c.tar.xz
ice-a5bd24845a2720d57a66d81effc59423d723c87c.zip
ICE-6481 pragma comment when building static libraries
On windows with VS, pragma comment is now defined when building only when ICE_BUILDING_<component-name> is not defined. ICE_BUILDING_<component-name> is defined automatically when <component-name>_API_EXPORTS is defined. When building static Ice libraries on Windows, please define ICE_BUILDING_<component-name-being-built>. ICE_DECLSPEC_EXPORT and ICE_DECLSPEC_IMPORT are now defined all the time on Windows, and we define the various _API macros to /**/ when ICE_STATIC_LIBS is defined. Replaced various direct use of ICE_DECLSPEC_EXPORT/ICE_DECLSPEC_IMPORT by the correct _API macro.
Diffstat (limited to 'cpp/include')
-rw-r--r--cpp/include/Freeze/Initialize.h10
-rw-r--r--cpp/include/Glacier2/Config.h13
-rw-r--r--cpp/include/Glacier2/NullPermissionsVerifier.h2
-rw-r--r--cpp/include/Ice/Config.h19
-rw-r--r--cpp/include/IceBox/Config.h13
-rw-r--r--cpp/include/IceGrid/Config.h13
-rw-r--r--cpp/include/IcePatch2/Config.h13
-rw-r--r--cpp/include/IceSSL/Plugin.h13
-rw-r--r--cpp/include/IceStorm/Config.h13
-rw-r--r--cpp/include/IceUtil/Config.h18
-rw-r--r--cpp/include/Slice/Parser.h15
-rw-r--r--cpp/include/Slice/Preprocessor.h2
12 files changed, 93 insertions, 51 deletions
diff --git a/cpp/include/Freeze/Initialize.h b/cpp/include/Freeze/Initialize.h
index 77b99acc924..1f80407e77f 100644
--- a/cpp/include/Freeze/Initialize.h
+++ b/cpp/include/Freeze/Initialize.h
@@ -19,11 +19,13 @@
//
// Automatically link Freeze[D].lib with Visual C++
//
+#if !defined(ICE_BUILDING_FREEZE) && defined(FREEZE_API_EXPORTS)
+# define ICE_BUILDING_FREEZE
+#endif
+
#ifdef _MSC_VER
-# if defined(ICE_STATIC_LIBS)
-# pragma comment(lib, "Freeze.lib")
-# elif !defined(FREEZE_API_EXPORTS)
-# if defined(_DEBUG)
+# if !defined(ICE_BUILDING_FREEZE)
+# if defined(_DEBUG) && !defined(ICE_OS_WINRT)
# pragma comment(lib, "FreezeD.lib")
# else
# pragma comment(lib, "Freeze.lib")
diff --git a/cpp/include/Glacier2/Config.h b/cpp/include/Glacier2/Config.h
index 280a49e2409..9f4efe2b040 100644
--- a/cpp/include/Glacier2/Config.h
+++ b/cpp/include/Glacier2/Config.h
@@ -10,14 +10,17 @@
#ifndef GLACIER2_CONFIG_H
#define GLACIER2_CONFIG_H
-#ifdef _MSC_VER
//
// Automatically link with Glacier2[D].lib
//
-# if defined(ICE_STATIC_LIBS)
-# pragma comment(lib, "Glacier2.lib")
-# elif !defined(GLACIER2_API_EXPORTS)
-# if defined(_DEBUG)
+
+#if !defined(ICE_BUILDING_GLACIER2) && defined(GLACIER2_API_EXPORTS)
+# define ICE_BUILDING_GLACIER2
+#endif
+
+#ifdef _MSC_VER
+# if !defined(ICE_BUILDING_GLACIER2)
+# if defined(_DEBUG) && !defined(ICE_OS_WINRT)
# pragma comment(lib, "Glacier2D.lib")
# else
# pragma comment(lib, "Glacier2.lib")
diff --git a/cpp/include/Glacier2/NullPermissionsVerifier.h b/cpp/include/Glacier2/NullPermissionsVerifier.h
index b18230fb212..fbb868c42f3 100644
--- a/cpp/include/Glacier2/NullPermissionsVerifier.h
+++ b/cpp/include/Glacier2/NullPermissionsVerifier.h
@@ -18,6 +18,8 @@
#ifndef GLACIER2_API
# ifdef GLACIER2_API_EXPORTS
# define GLACIER2_API ICE_DECLSPEC_EXPORT
+# elif defined(ICE_STATIC_LIBS)
+# define GLACIER2_API /**/
# else
# define GLACIER2_API ICE_DECLSPEC_IMPORT
# endif
diff --git a/cpp/include/Ice/Config.h b/cpp/include/Ice/Config.h
index 6acc0784de3..8dbfb467c06 100644
--- a/cpp/include/Ice/Config.h
+++ b/cpp/include/Ice/Config.h
@@ -35,11 +35,14 @@
//
// Automatically link Ice[D].lib with Visual C++
//
-#if defined(_MSC_VER) && !defined(ICE_NO_PRAGMA_COMMENT)
-# if defined(ICE_STATIC_LIBS)
-# pragma comment(lib, "Ice.lib")
-# elif !defined(ICE_API_EXPORTS)
-# if defined(_DEBUG)
+
+#if !defined(ICE_BUILDING_ICE) && defined(ICE_API_EXPORTS)
+# define ICE_BUILDING_ICE
+#endif
+
+#if defined(_MSC_VER)
+# if !defined(ICE_BUILDING_ICE)
+# if defined(_DEBUG) && !defined(ICE_OS_WINRT)
# pragma comment(lib, "IceD.lib")
# else
# pragma comment(lib, "Ice.lib")
@@ -65,9 +68,11 @@ namespace IceInternal
#ifndef ICE_API
# ifdef ICE_API_EXPORTS
# define ICE_API ICE_DECLSPEC_EXPORT
-# else
+# elif defined(ICE_STATIC_LIBS)
+# define ICE_API /**/
+# else
# define ICE_API ICE_DECLSPEC_IMPORT
-# endif
+# endif
#endif
namespace Ice
diff --git a/cpp/include/IceBox/Config.h b/cpp/include/IceBox/Config.h
index b95e5bf1700..fa925dd6e86 100644
--- a/cpp/include/IceBox/Config.h
+++ b/cpp/include/IceBox/Config.h
@@ -10,14 +10,17 @@
#ifndef ICE_BOX_CONFIG_H
#define ICE_BOX_CONFIG_H
-#ifdef _MSC_VER
//
// Automatically link with IceBox[D].lib
//
-# if defined(ICE_STATIC_LIBS)
-# pragma comment(lib, "IceBox.lib")
-# elif !defined(ICE_BOX_API_EXPORTS)
-# if defined(_DEBUG)
+
+#if !defined(ICE_BUILDING_ICE_BOX) && defined(ICE_BOX_API_EXPORTS)
+# define ICE_BUILDING_ICE_BOX
+#endif
+
+#ifdef _MSC_VER
+# if !defined(ICE_BUILDING_ICE_BOX)
+# if defined(_DEBUG) && !defined(ICE_OS_WINRT)
# pragma comment(lib, "IceBoxD.lib")
# else
# pragma comment(lib, "IceBox.lib")
diff --git a/cpp/include/IceGrid/Config.h b/cpp/include/IceGrid/Config.h
index eafc2a1827e..c86a38ef3cf 100644
--- a/cpp/include/IceGrid/Config.h
+++ b/cpp/include/IceGrid/Config.h
@@ -10,14 +10,17 @@
#ifndef ICE_GRID_CONFIG_H
#define ICE_GRID_CONFIG_H
-#ifdef _MSC_VER
//
// Automatically link with IceGrid[D].lib
//
-# if defined(ICE_STATIC_LIBS)
-# pragma comment(lib, "IceGrid.lib")
-# elif !defined(ICE_GRID_API_EXPORTS)
-# if defined(_DEBUG)
+
+#if !defined(ICE_BUILDING_ICE_GRID) && defined(ICE_GRID_API_EXPORTS)
+# define ICE_BUILDING_ICE_GRID
+#endif
+
+#ifdef _MSC_VER
+# if !defined(ICE_BUILDING_ICE_GRID)
+# if defined(_DEBUG) && !defined(ICE_OS_WINRT)
# pragma comment(lib, "IceGridD.lib")
# else
# pragma comment(lib, "IceGrid.lib")
diff --git a/cpp/include/IcePatch2/Config.h b/cpp/include/IcePatch2/Config.h
index 0a5608eb122..12457f45e7a 100644
--- a/cpp/include/IcePatch2/Config.h
+++ b/cpp/include/IcePatch2/Config.h
@@ -10,14 +10,17 @@
#ifndef ICE_PATCH2_CONFIG_H
#define ICE_PATCH2_CONFIG_H
-#ifdef _MSC_VER
//
// Automatically link with IcePatch2[D].lib
//
-# if defined(ICE_STATIC_LIBS)
-# pragma comment(lib, "IcePatch2.lib")
-# elif !defined(ICE_PATCH2_API_EXPORTS)
-# if defined(_DEBUG)
+
+#if !defined(ICE_BUILDING_ICE_PATCH2) && defined(ICE_PATCH2_API_EXPORTS)
+# define ICE_BUILDING_ICE_PATCH2
+#endif
+
+#ifdef _MSC_VER
+# if !defined(ICE_BUILDING_ICE_PATCH2)
+# if defined(_DEBUG) && !defined(ICE_OS_WINRT)
# pragma comment(lib, "IcePatch2D.lib")
# else
# pragma comment(lib, "IcePatch2.lib")
diff --git a/cpp/include/IceSSL/Plugin.h b/cpp/include/IceSSL/Plugin.h
index 367fd73c5dd..772ce4225a1 100644
--- a/cpp/include/IceSSL/Plugin.h
+++ b/cpp/include/IceSSL/Plugin.h
@@ -21,9 +21,14 @@
//
// Automatically link IceSSL[D].lib with Visual C++
//
-#if defined(_MSC_VER) && !defined(ICE_NO_PRAGMA_COMMENT)
-# if !defined(ICE_STATIC_LIBS) && !defined(ICE_SSL_API_EXPORTS)
-# if defined(_DEBUG)
+
+#if !defined(ICE_BUILDING_ICE_SSL) && defined(ICE_SSL_API_EXPORTS)
+# define ICE_BUILDING_ICE_SSL
+#endif
+
+#if defined(_MSC_VER)
+# if !defined(ICE_BUILDING_ICE_SSL)
+# if defined(_DEBUG) && !defined(ICE_OS_WINRT)
# pragma comment(lib, "IceSSLD.lib")
# else
# pragma comment(lib, "IceSSL.lib")
@@ -47,6 +52,8 @@
#ifndef ICE_SSL_API
# ifdef ICE_SSL_API_EXPORTS
# define ICE_SSL_API ICE_DECLSPEC_EXPORT
+# elif defined(ICE_STATIC_LIBS)
+# define ICE_SSL_API /**/
# else
# define ICE_SSL_API ICE_DECLSPEC_IMPORT
# endif
diff --git a/cpp/include/IceStorm/Config.h b/cpp/include/IceStorm/Config.h
index b072ce43827..0a7f3cb9794 100644
--- a/cpp/include/IceStorm/Config.h
+++ b/cpp/include/IceStorm/Config.h
@@ -10,14 +10,17 @@
#ifndef ICE_STORM_CONFIG_H
#define ICE_STORM_CONFIG_H
-#ifdef _MSC_VER
//
// Automatically link with IceStorm[D].lib
//
-# if defined(ICE_STATIC_LIBS)
-# pragma comment(lib, "IceStorm.lib")
-# elif !defined(ICE_STORM_LIB_API_EXPORTS)
-# if defined(_DEBUG)
+
+#if !defined(ICE_BUILDING_ICE_STORM_LIB) && defined(ICE_STORM_LIB_API_EXPORTS)
+# define ICE_BUILDING_ICE_STORM_LIB
+#endif
+
+#ifdef _MSC_VER
+# if !defined(ICE_BUILDING_ICE_STORM_LIB)
+# if defined(_DEBUG) && !defined(ICE_OS_WINRT)
# pragma comment(lib, "IceStormD.lib")
# else
# pragma comment(lib, "IceStorm.lib")
diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h
index 471fe9881c5..c834d1c0c3c 100644
--- a/cpp/include/IceUtil/Config.h
+++ b/cpp/include/IceUtil/Config.h
@@ -97,7 +97,7 @@
// Compiler extensions to export and import symbols: see the documentation
// for Visual Studio, Solaris Studio and GCC.
//
-#if defined(_WIN32) && !defined(ICE_STATIC_LIBS)
+#if defined(_WIN32)
# define ICE_DECLSPEC_EXPORT __declspec(dllexport)
# define ICE_DECLSPEC_IMPORT __declspec(dllimport)
//
@@ -118,8 +118,10 @@
//
// Let's use these extensions with IceUtil:
//
-#ifdef ICE_UTIL_API_EXPORTS
+#if defined(ICE_UTIL_API_EXPORTS)
# define ICE_UTIL_API ICE_DECLSPEC_EXPORT
+#elif defined(ICE_STATIC_LIBS)
+# define ICE_UTIL_API /**/
#else
# define ICE_UTIL_API ICE_DECLSPEC_IMPORT
#endif
@@ -173,17 +175,19 @@
# include <TargetConditionals.h>
#endif
-#if defined(_MSC_VER) && !defined(ICE_NO_PRAGMA_COMMENT)
+#if !defined(ICE_BUILDING_ICE_UTIL) && defined(ICE_UTIL_API_EXPORTS)
+# define ICE_BUILDING_ICE_UTIL
+#endif
+
+#if defined(_MSC_VER)
# if !defined(ICE_STATIC_LIBS) && (!defined(_DLL) || !defined(_MT))
# error "Only multi-threaded DLL libraries can be used with Ice!"
# endif
//
// Automatically link with IceUtil[D].lib
//
-# if defined(ICE_STATIC_LIBS)
-# pragma comment(lib, "IceUtil.lib")
-# elif !defined(ICE_UTIL_API_EXPORTS)
-# if defined(_DEBUG)
+# if !defined(ICE_BUILDING_ICE_UTIL)
+# if defined(_DEBUG) && !defined(ICE_OS_WINRT)
# pragma comment(lib, "IceUtilD.lib")
# else
# pragma comment(lib, "IceUtil.lib")
diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h
index 257e1df5987..2ca3e84bfc4 100644
--- a/cpp/include/Slice/Parser.h
+++ b/cpp/include/Slice/Parser.h
@@ -23,11 +23,14 @@
//
// Automatically link Slice[D].lib with Visual C++
//
-#if defined(_MSC_VER) && !defined(ICE_NO_PRAGMA_COMMENT)
-# if defined(ICE_STATIC_LIBS)
-# pragma comment(lib, "Slice.lib")
-# elif !defined(SLICE_API_EXPORTS)
-# if defined(_DEBUG)
+
+#if !defined(ICE_BUILDING_SLICE) && defined(SLICE_API_EXPORTS)
+# define ICE_BUILDING_SLICE
+#endif
+
+#if defined(_MSC_VER)
+# if !defined(ICE_BUILDING_SLICE)
+# if defined(_DEBUG) && !defined(ICE_OS_WINRT)
# pragma comment(lib, "SliceD.lib")
# else
# pragma comment(lib, "Slice.lib")
@@ -38,6 +41,8 @@
#ifndef SLICE_API
# ifdef SLICE_API_EXPORTS
# define SLICE_API ICE_DECLSPEC_EXPORT
+# elif defined(ICE_STATIC_LIBS)
+# define SLICE_API /**/
# else
# define SLICE_API ICE_DECLSPEC_IMPORT
# endif
diff --git a/cpp/include/Slice/Preprocessor.h b/cpp/include/Slice/Preprocessor.h
index 08125e0fb2f..1e109c09e73 100644
--- a/cpp/include/Slice/Preprocessor.h
+++ b/cpp/include/Slice/Preprocessor.h
@@ -17,6 +17,8 @@
#ifndef SLICE_API
# ifdef SLICE_API_EXPORTS
# define SLICE_API ICE_DECLSPEC_EXPORT
+# elif defined(ICE_STATIC_LIBS)
+# define SLICE_API /**/
# else
# define SLICE_API ICE_DECLSPEC_IMPORT
# endif