On Saturday, 21 December 2013 at 01:57:50 UTC, Casper Færgemand wrote:
Having skimmed core.stdc.stdio.d now, it's seems pretty manageable to parse, so we'll go with that. Thankies. :3

cool. Also make note of the "extern(C):" on line 30 of that file: the colon applies that thing to everything after it, so the whole file is extern(C) (and nothrow and @system, unless overridden later0

Also, the druntime import names follow a simple pattern:

core.stdc.* -> #include<*.h> in C. so stdio.h is core.stdc.stdio, stdlib.h is core.stdc.stdlib, and so on. This only covers standard C functions, some C includes won't be there since they are non-standard extensions.

There's also includes for other operating systems in

core.sys.OS_NAME.FILE

so

import core.sys.posix.unistd; is #include<unistd.h> in C on Posix systems (linux, etc.)

core.sys.linux.* is Linus specific extensions.

core.sys.posix.sys.socket == #include<sys/socket.h>


And there's also core.sys.windows.windows for Windows stuff, though this is really incomplete. So if you do much work with the Win32 API you'll want to download the more complete bindings
http://www.dsource.org/projects/bindings/browser/trunk/win32

There's a bunch of other C libs done in here too:
https://github.com/D-Programming-Deimos



Or, you can avoid doing the modules by just copy/pasting the extern(C) definitions you need to call yourself. That can get a bit tricky translating macros and structs from C, you'll have to be sure to get the types right (A "long" in C isn't the same as a "long" in D for instance), but this isn't too hard either.

So if something isn't already done in the deimos collection, you can still use the C libraries (or other C files you write) just by getting those function prototypes done like i did in my last message.

Reply via email to