The CAPI Manifesto
Michel Fortin
michel.fortin at michelf.com
Mon Oct 17 05:01:39 PDT 2011
On 2011-10-17 10:21:45 +0000, Sean Kelly <sean at 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?
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list