C standard libraries

Adam D. Ruppe destructionator at gmail.com
Mon Jul 1 09:45:30 PDT 2013


On Monday, 1 July 2013 at 16:32:32 UTC, CJS wrote:
> Is there some header/module that includes declaration for all C 
> standard libraries?

It is in core.stdc. For example:

import core.stdc.stdio; // <stdio.h>
import core.stdc.stdlib;// <stdlib.h>

etc.

> what in D--even after looking through the docs--would do 
> something equivalent to clock and CLOCKS_PER_SEC in the C 
> standard library time.h.

import core.stdc.time;

import std.stdio; // for writeln
writeln(CLOCKS_PER_SEC);


The C headers in D aren't much documented, but they have all the 
same stuff as in C itself, so if you translate the include to 
import, the rest should continue to just work.


If you want to get to more OS specific stuff, outside the C 
standard but still typical C libs, it is core.sys.posix.unistd; 
/* <unistd.h> */ core.sys.windows.windows /* <windows.h> */ and 
so on.

The windows.h translation is *horribly* incomplete though, so if 
you want to do a serious win32 program you'll probably want to 
get something else. There's a win32 bindings somewhere on the 
net, if you need it I can find the link.


More information about the Digitalmars-d-learn mailing list