[cairo] cairo compiles on win32 (cygwin)

Turner David dturner at cptechno.com
Fri Jan 23 07:17:54 PST 2004


Hello,

> That may be right. I guess I could've been a little more clear. I 
> removed the code for two reasons:
> 1) It did not seem to be implemented correctly. Every example 
> code and 
> piece of documentation that I could find on the subject had the 
> __declspec(dllexport) at the beginning of the fuction declaration, 
> before the type. Ex:
> 
>     __external_linkage void
>     foo (int bar);
> 
> The implementations I pulled out looked like this:
> 
>     extern void __external_linkage
>     foo (int bar);
> 
> In trying to get it to compile I tried many different things 
> and in the 
> end took it out. Now it looks like this:
> 
>     void
>     foo (int bar);
> 

As an historical note, I believe that early Borland compilers
required the __declspec(dllexport) to be placed between the
function's type and name, as in:

    void __external_linkage  foo( int bar );

that's why many portable libraries that try to deal with this
problem used to either:

 - use two distinct macros (one before, then one after the type)

 - use a function macro like:

        #if BUILD_DLL
        #  if  defined(OLD_BORLAND_COMPILER)
        #    define  EXPORTED(x)   x __declspec(dllexport)
        #  else
        #    define  EXPORTED(x)   __declspec(dllexport) x
        #else
        #  define  EXPORTED(x)   extern x
        #endif

        ...

        EXPORTED( void )  foo( int  bar );

Note however that the current crop of Borland C/C++ compilers
will accept the __declspec(dllexport) before or after the type
anyway, so this issue is not as important as it used to be;
at least on Windows.

For Cairo, you could try this scheme with:

    #if defined(WIN32) || defined(__CYGWIN__)
    #  define   CAIRO_API(x)   extern x
    #else
    #  define   CAIRO_API(x)   __external_linkage x
    #endif

    ...

    CAIRO_API( void )   cairo_foo( int  bar );


Hope this helps,

- David Turner
- The FreeType Project  (www.freetype.org)


> 2) As far as I could tell, while the code was win32 and even cygwin 
> specifig (the macro was defined only #if defined(WIN32) || 
> defined(__CYGWIN__)), the code was not added by someone trying to get 
> cairo to compile under win32 or cygwin. This was code from the slim 
> library. I couldn't find anything on the mailing list suggesting that 
> anyone was able to compile cairo for win32 or cygwin without 
> modifications (and that was my goal) so I felt ok taking it out.
> 
> If someone were to compile in some other win32 environment (not 
> unreasonable) it may turn out that it is necessary. I would 
> feel better 
> about them adding it for that reason. Until then the code is a lot 
> easier to read.
> 
> Thanks
> 
> - Richard D. Worth
> richard at theworths.org
> 
> 
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
> 

--
This message and any attachments (the "message") is intended solely for the
addressees and is confidential. If you receive this message in error, please
delete it and immediately notify the sender.
Any use not in accordance with its purpose, any dissemination or disclosure,
either whole or partial, is prohibited except formal approval.
The E-Mail transmission can not guarantee the integrity of this message.
NDS TECHNOLOGIES FRANCE will not therefore be liable for the message if modified.






More information about the cairo mailing list