[cairo] Cairo ported to OS/2 - Suggestions

Carl Worth cworth at cworth.org
Tue Aug 16 15:34:40 PDT 2005


On Tue, 16 Aug 2005 11:02:52 +0200, Doodle wrote:
> I've managed to port Cairo to OS/2,

That is definitely remarkable.

> So, my proposal, for which I'd like to hear your opinions, is to
> modify the public API to something like this:
> 
> CAIRODECLSPEC cairo_t * CAIROCALL
> cairo_create (cairo_surface_t *target);
> 
> CAIRODECLSPEC void CAIROCALL
> cairo_destroy (cairo_t *cr);

I find that really, really hard to read. It's very difficult to parse
out the return types since they are buried in a lot of noise.

If we do have to clutter up the public header at all, (which I'd like
to avoid, see below), I would at least like to hide this stuff from
human eyes as much as possible. Perhaps something like:

							CAIRO_DECL_ANTE
cairo_t *						CAIRO_DECL_POST
cairo_create (cairo_surface_t *target);

> #else
> /* Use __cdecl for all other platforms */
> #define CAIROCALL __cdecl
> #endif

Can you explain this __cdecl thing to me more clearly? I can't find
any mention of this in the C99 specification, and if I try putting
"__cdecl" in function prototypes my compiler reports a syntax error.

I'm definitely grumpy about adding non-C things to a public header
file. I did concede to put the 'extern "C"' thing there, so my
grumpiness can be overcome, but I'll need to see a compelling reason
first.

You said this calling convention thing could be controlled by compiler
switches. It seems like a compiler-specific feature to me. Is there a
reason that compiler switches shouldn't be the thing used to control
it?

> In addition to solving my problem, it would have one more advantage:
> By using the CAIRODECLSPEC defined above, it would be controlled from
> the source code which functions are exported and which are not. I think
> it's always better to let others use only those functions we let them
> to use.

We've currently got support in cairoint.h to hide non-public symbols
when using gcc >= 3 on elf-based platforms.

I agree that the symbol visibility issue is important, but I
definitely want to solve it in places other than cairo.h. The primary
consumers of cairo.h are humans that don't need to be told about
public vs. private symbols, (since the file only contains public
symbols).

> (And being a bit of selfish here: it would save me a lot of job,
> because right now I have to tell the OpenWatcom linker which
> functions to export, but if the code would have these defines,
> the linker would know them automatically.)

I think it would be quite easy to write a little script that extracts
the public symbols out of the header files. There's a small list of
public header files, all of which have a fairly rigid style, and there
are no public symbols that are not in those files. So, if we could
construct such a list of symbols in a file, and provide it with the
cairo source distribution, would that be sufficient for you to do what
you what you need to do?

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050816/159e6648/attachment.pgp


More information about the cairo mailing list