On Fri, 24 Sep 2010, Peter Rosin wrote:

Hi!
I don't know how to set up the defines so that EXTERN becomes

1. "extern" when you use a static library
2. "extern" when you build a static library
3. "extern declspec(dllimport)" when you use a shared library
4. "extern declspec(dllexport)" when you build a shared library

I could fix 2 and 4, but separating 1 and 3 is not possible. Since
extern declspec(dllimport) works everywhere with MSVC I'm taking the
easy option with this patch.

Or should I add -DBUILDING_FOO to Makefile.am and variations of the below
to the code?

#ifdef _MSC_VER
# ifdef BUILDING_FOO
#  ifdef DLL_EXPORT
#   define EXTERN extern declspec(dllexport)
#  endif
# else
#  define EXTERN extern declspec(dllimport)
# endif
#endif
#ifndef EXTERN
# define EXTERN extern
#endif

here is what I use:

http://trac.enlightenment.org/e/browser/trunk/PROTO/evil/src/lib/Evil.h#L7

It's what you do, with just an additional else in DLL_EXPORT case, without your #ifndef.

works fine with gcc (mingw, mingw-w64, mingw32ce) and vc++

hth

Vincent Torri

Reply via email to