The CAPI Manifesto

Sean Kelly sean at invisibleduck.org
Mon Oct 17 03:21:45 PDT 2011


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.

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.



More information about the Digitalmars-d mailing list