[Distutils] DEF Files

M.-A. Lemburg mal@lemburg.com
Tue, 14 Sep 1999 12:13:41 +0200


Anthony Pfrunder wrote:
> 
> On Tue, 14 Sep 1999, Robert Kern wrote:
> 
> > FWIW, I agree with David that requiring modifying the source of an
> > extension is not a good thing.  It only adds a headache for people trying to port from *NIX to
> > Windows (and we have enough to deal with,
> > believe me), and it pollutes the code with weird MS extensions.
> ... and weird unix only utilites such as sed [sorry, my Windows side speaking]

I don't really get your points here... you can stick all those
weird symbols into macros and then forget about them.

Writing...

#include "mxh.h"
MX_EXPORT(void)
     initmxODBC(void)
{
}

...isn't all that bad and makes the intention pretty clear. Here's
the contents of mxh.h:

/* Macro to "mark" a symbol for DLL export */

#if defined(_MSC_VER) && _MSC_VER > 850 /* MS VC++ 2.0 and up */
# ifdef __cplusplus
#   define MX_EXPORT(type) extern "C" type __declspec(dllexport) 
# else
#   define MX_EXPORT(type) extern type __declspec(dllexport) 
# endif
#elif defined(__WATCOMC__)
#   define MX_EXPORT(type) extern type __export 
#else
#   define MX_EXPORT(type) extern type
#endif

/* Macro to "mark" a symbol for DLL import */

#if defined(__BORLANDC__)
#   define MX_IMPORT(type) extern type __import
#elif defined(_MSC_VER) && _MSC_VER > 850 /* MS VC++ 2.0 and up */
# ifdef __cplusplus
#   define MX_IMPORT(type) extern "C" type __declspec(dllimport)
# else
#   define MX_IMPORT(type) extern type __declspec(dllimport)
# endif
#else
#   define MX_IMPORT(type) extern type
#endif

BTW, additions to support more compilers are always welcome.
The above works for pretty much all Unix, Mac and Windows compilers
people have used to compile my extensions, so I guess its pretty
generic.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Y2000:                                                   108 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/