[cairo] _cairo_win32_tmpfile()
Behdad Esfahbod
behdad at behdad.org
Fri Sep 26 10:11:05 PDT 2008
Augusto Radtke wrote:
>> That's indeed very untested. You mean, if CAIRO_WIN32_STATIC_BUILD is defined
>> we should define cairo_public to nothing? That makes sense, does this work
>> better:
>>
>> #ifndef cairo_public
>> # if _MSC_VER && ! CAIRO_WIN32_STATIC_BUILD
>> # define cairo_public __declspec(dllimport)
>> # else
>> # define cairo_public
>> # endif
>> #endif
>
> It's getting better, but there is another issue, we should use
> __declspec(dllexport) when building a DLL. I can't found yet a way to
> make that work without some define at some point of the process, like
> CAIRO_WIN32_STATIC_BUILD, this is how I solved the problem internally
> on my software:
The very first thing cairoint.h does is:
#ifdef _MSC_VER
#define cairo_public __declspec(dllexport)
#endif
Is that not working for you? All source files includes cairoint.h before
anything else.
behdad
> #if defined(_WIN32)
> #if defined(SCULLY_API_EXPORT)
> #define SCULLY_API __declspec(dllexport)
> #elif defined(SCULLY_API_IMPORT)
> #define SCULLY_API __declspec(dllimport)
> #else
> #define SCULLY_API
> #endif
> #else
> #if defined(SCULLY_API_IMPORT)
> #define SCULLY_API extern
> #else
> #define SCULLY_API
> #endif
> #endif
>
> The default here it's to build statically, so if I'm building
> statically I don't have to define nothing on either points (library
> compilation and library usage by third party). If I'm not compiling
> statically I define SCULLY_API_EXPORT when compiling the library and
> SCULLY_API_IMPORT on using the library headers. I believe cairo as
> open-source it's mostly used as an external library instead of being
> building statically, so it should stand for a different default:
>
> #ifndef cairo_public
> #if _MSC_VER && CAIRO_WIN32_BUILD_DLL
> #define cairo_public __declspec(dllexport)
> #elif _MSC_VER && !CAIRO_WIN32_BUILD_DLL
> #define cairo_public __declspec(dllimport)
> #elif CAIRO_WIN32_BUILD_DLL
> #define cairo_public extern
> #else
> #define cairo_public
> #endif
> #endif
>
> That means that we should always build cairo with
> CAIRO_WIN32_BUILD_DLL set if we are building a DLL, but the person
> using that DLL can go direct to #include <cairo.h> without caring
> about any magic define. Also if the person want a static build of
> cairo it can build directly and use directly without magic define. The
> responsibility of setting correct defines goes to the DLL builder. The
> extern defined on the second #elif is to people building a DLL on GCC,
> does it use extern as somekind of __declspec(dllexport)? This is
> something I need some light from someone else.
>
> Augusto
>
More information about the cairo
mailing list