Wireshark-dev: Re: [Wireshark-dev] Win32: get rid of the xy.def files?!?
From: Jaap Keuter <jaap.keuter@xxxxxxxxx>
Date: Thu, 25 Jan 2007 07:46:26 +0100 (CET)
Hi,

Reading the previously quoted thread, why not use the facilities provided
by gmodule.h?

/* exporting and importing functions, this is special cased
 * to feature Windows dll stubs.
 */
#define	G_MODULE_IMPORT		extern
#ifdef G_PLATFORM_WIN32
#  define	G_MODULE_EXPORT		__declspec(dllexport)
#else /* !G_PLATFORM_WIN32 */
#  define	G_MODULE_EXPORT
#endif /* !G_PLATFORM_WIN32 */

Thanx,
Jaap

On Wed, 24 Jan 2007, Ulf Lamping wrote:

> Hi List!
>
> The current way we handle Win32 DLL export of symbols is a bit odd in my eyes.
>
> You'll have to add the symbol name to a .def file. If it is a variable, in addition to this you'll need to append DATA to this entry and add WS_VAR_IMPORT to the corresponding header file.
>
>
> A cleaner way seems to be using the __declspec(dllimport / dllexport) definitions "the right way", as MS itself promotes it e.g. in: http://msdn2.microsoft.com/fr-fr/library/8fskxacy(VS.71).aspx
>
> The "trick" is to add something like:
>
> #ifdef _EXPORTING
> #define WS_SYMBOL_IMEXPORT	__declspec(dllexport)
> #else
> #define WS_SYMBOL_IMEXPORT	__declspec(dllimport)
> #endif
>
> to config.h.win32 - as _EXPORTING is automatically set by the compiler - and a corresponding dummy entry "#define WS_SYMBOL_IMEXPORT" to the automake config file so we dont get compiler errors on UNIX builds.
>
> This way you'll simply add WS_SYMBOL_IMEXPORT to the header file to im/export a symbol, e.g.:
>
> WS_SYMBOL_IMEXPORT int eth_stdio_open (...
>
> ... and your done! Ive tried this successfully with function names, DATA symbols should also work the same way.
>
>
> This has several advantages over the current solution:
>
> - no need for seperate .def files
> - no need to add things at two places for a DATA symbol (often forgotten)
> - easily rename / delete functions without worrying about the .def file
>
>
> Any objections against this (in my eyes cleaner) solution?
>
> Regards, ULFL
>
> P.S: A better name than WS_SYMBOL_IMEXPORT would be nice, any ideas? Or is it ok?
> _____________________________________________________________________
> Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> http://smartsurfer.web.de/?mc=100071&distributionid=000000000066
>
> _______________________________________________
> Wireshark-dev mailing list
> Wireshark-dev@xxxxxxxxxxxxx
> http://www.wireshark.org/mailman/listinfo/wireshark-dev
>
>