* __attribute__((visibility("hidden"))) - "type attributes are honored only at type definition"
@ 2005-05-18 22:20 Christian Parpart
0 siblings, 0 replies; only message in thread
From: Christian Parpart @ 2005-05-18 22:20 UTC (permalink / raw)
To: gcc-help; +Cc: Sebastian Moleski
[-- Attachment #1: Type: text/plain, Size: 2109 bytes --]
Hi all,
I'm writing (together with a friend) a cross platform library. however, I
recently introduced the machanism to export only those *wanted* symbols.
On the GCC/linux side, it's quite clear (for me) how to do this. But for the
windows/MSVC side, I'm really not familar in any way.
Now, to get the code together, we introduced a #macro that declares those
symbols to be exportable like the following:
// general API export/import macros
#if defined(SW_GCC)
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
// XXX visibility is available in GCC 3.4 and higher
# define SW_EXPORT __attribute__((visibility("default")))
# define SW_NO_EXPORT __attribute__((visibility("hidden")))
# define SW_IMPORT /*!*/
# else
# define SW_EXPORT /*!*/
# define SW_NO_EXPORT /*!*/
# define SW_IMPORT /*!*/
# endif
#elif SW_WIN32
# define SW_EXPORT __declspec(dllexport)
# define SW_NO_EXPORT /*!*/
# define SW_IMPORT /*__declspec(dllimport)*/
#else
# define SW_EXPORT /*!*/
# define SW_NO_EXPORT /*!*/
# define SW_IMPORT /*!*/
#endif
// SWL API export/import
#if defined(MAKE_SWL)
# define SWL_API SW_EXPORT
#else
# define SWL_API SW_IMPORT
#endif
Now, defining a symbol with this SW_EXPORT modifier is quite okay, but on the
windows side, my friend says, he *NEEDS* this to be done for forward
declarations as well. *ANYWHERE* he forward declares symbol "foo" to be
exportable/importable, that symbol declaration has to have that SWL_API macro
between as well.
This doesn't like GCC (obviousely) and complains about like this:
module.h:line: warning: type attributes are honored only at type definition
in a line like this:
template<class T> class SWL_API TSharedPtr;
Now... in how far is this right and/or how could we find a Windows/Linux
compatible macro-way to make each compiler/linker happy here?
Thanks in advance,
Christian Parpart.
--
Netiquette: http://www.ietf.org/rfc/rfc1855.txt
00:10:38 up 56 days, 13:17, 2 users, load average: 1.44, 2.11, 1.92
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-05-18 22:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-18 22:20 __attribute__((visibility("hidden"))) - "type attributes are honored only at type definition" Christian Parpart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).