On 2011-10-17 14:01, Michel Fortin wrote:
On 2011-10-17 10:21:45 +0000, Sean Kelly <s...@invisibleduck.org> said:

On Oct 16, 2011, at 7:02 PM, Walter Bright wrote:

The CAPI Manifesto
------------------

CAPI is a collection of C header files to publicly available C
libraries
and their translations to D. The idea is that if, in C, to interface
to a library
one would write:

#include "foo.h"

then the corresponding D code would look like:

import foo;

If the C header file has a name that is a D keyword, an underscore will
be appended to the D module name. If a C type name matches a C function
name (stat), the type name will have a "_t" appended.

Hum, but _t in C stands for typedef. Wouldn't it be better to just
append an underscore like for module names, that'd make only one rule to
remember.


There's also the occasional issue of something that doesn't translate
into D. As one slightly weird example, some of the the Posix routines
in OSX have alternates with odd suffixes like "$2003" that are the
versions which should be called on newer versions of the OS. I'm still
not sure of the best way to handle this, since D doesn't have macros.

I think what D needs to handle that is some pragma to manually specify
the mangled name of a given function. Why would you need macros?

Perhaps the macro is used to determine if "foo" or "foo$2003" is supposed to be called, based on some condition.

--
/Jacob Carlborg

Reply via email to