digitalmars.D.learn - C standard libraries
- CJS (7/7) Jul 01 2013 Is there some header/module that includes declaration for all C
- Adam D. Ruppe (19/24) Jul 01 2013 It is in core.stdc. For example:
- CJS (7/11) Jul 01 2013 Thanks! I'm confused why that module isn't mentioned in the
- bearophile (4/9) Jul 01 2013 Use core.stdc, and forget of std.c.
- Gary Willoughby (1/4) Jul 02 2013 What's the reason for that?
- bearophile (7/8) Jul 02 2013 Moving the C stuff in core is probably a way to remember D
- Adam D. Ruppe (15/18) Jul 02 2013 std.c is what it was called in earlier versions of D, before
- bearophile (11/16) Jul 02 2013 In D/Phobos/Dmd there is a ton of stuff that's supposed to be
- Gary Willoughby (4/21) Jul 09 2013 I agree.
- Timothee Cour (5/21) Jul 10 2013 at the very least it should go in http://dlang.org/deprecate.html even i...
- Jonathan M Davis (6/14) Jul 01 2013 If you want to time a function, checkout std.datetime.StopWatch:
- John Colvin (4/17) Jul 02 2013 +1
Is there some header/module that includes declaration for all C standard libraries? I'm wondering both in general for future reference, and for the specific case of wanting to time a function and not knowing 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.
Jul 01 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.
Jul 01 2013
It is in core.stdc. For example: import core.stdc.stdio; // <stdio.h> import core.stdc.stdlib;// <stdlib.h> etc.Thanks! I'm confused why that module isn't mentioned in the library reference page. What's the difference between core.stdc and std.c? The docs do refer to core.stdc, though std.c.stdio in Phobos' source just imports core.stdc.stdio. The duplication seems a bit weird, and I'm wondering if one method is deprecated or migth be removed in the future.
Jul 01 2013
CJS:What's the difference between core.stdc and std.c? The docs do refer to core.stdc, though std.c.stdio in Phobos' source just imports core.stdc.stdio. The duplication seems a bit weird, and I'm wondering if one method is deprecated or migth be removed in the future.Use core.stdc, and forget of std.c. Bye, bearophile
Jul 01 2013
Use core.stdc, and forget of std.c. Bye, bearophileWhat's the reason for that?
Jul 02 2013
Gary Willoughby:What's the reason for that?Moving the C stuff in core is probably a way to remember D programmers that stuff is not normal stuff you are supposed to use in D programs. A D programmer should use the normal safer and nicer D functions. Core is there for special cases. Bye, bearophile
Jul 02 2013
On Tuesday, 2 July 2013 at 06:33:03 UTC, CJS wrote:Thanks! I'm confused why that module isn't mentioned in the library reference page.I don't know.What's the difference between core.stdc and std.c?std.c is what it was called in earlier versions of D, before there was a clear separation between phobos as the standard library (std.*) and druntime as the runtime library (core.*). Phobos is supposed to be 100% on top of druntime, so it is optional and interchangeable with ease. The runtime, however, needed access to some C functions for its own implementation. Since it isn't allowed to depend on std.*, the C functions got moved into core.*. The older std.c is kept around just for compatibility with the old names before the move, at least as far as I know. Maybe they haven't fully deprecated it though because there's other reasons I don't know about, since it has been many years now since the move.
Jul 02 2013
Adam D. Ruppe:The older std.c is kept around just for compatibility with the old names before the move, at least as far as I know. Maybe they haven't fully deprecated it though because there's other reasons I don't know about, since it has been many years now since the move.In D/Phobos/Dmd there is a ton of stuff that's supposed to be obsolete, that should not be used, that is deprecated, etc. I presume Walter thinks that the problems caused from keeping it and from unwanted usages of it, is smaller than the breaking troubles caused by removing it. I am person that likes to keeps things ordered and clean, so I prefer to remove old stuff after a suitable deprecation period, instead of keeping it around almost forever (like floating point special comparison operators). Bye, bearophile
Jul 02 2013
On Tuesday, 2 July 2013 at 12:52:49 UTC, bearophile wrote:Adam D. Ruppe:I agree. Also the website needs updating to deter people from using std.c: http://dlang.org/phobos/#stdioThe older std.c is kept around just for compatibility with the old names before the move, at least as far as I know. Maybe they haven't fully deprecated it though because there's other reasons I don't know about, since it has been many years now since the move.In D/Phobos/Dmd there is a ton of stuff that's supposed to be obsolete, that should not be used, that is deprecated, etc. I presume Walter thinks that the problems caused from keeping it and from unwanted usages of it, is smaller than the breaking troubles caused by removing it. I am person that likes to keeps things ordered and clean, so I prefer to remove old stuff after a suitable deprecation period, instead of keeping it around almost forever (like floating point special comparison operators). Bye, bearophile
Jul 09 2013
On Tue, Jul 2, 2013 at 5:52 AM, bearophile <bearophileHUGS lycos.com> wrote:Adam D. Ruppe: The older std.c is kept around just for compatibility with the old namesat the very least it should go in http://dlang.org/deprecate.html even if there's no timeline for deprecation (or even if it will never be deprecated) This should be the ONE destination to find out deprecated stuff or discouraged stuff.before the move, at least as far as I know. Maybe they haven't fully deprecated it though because there's other reasons I don't know about, since it has been many years now since the move.In D/Phobos/Dmd there is a ton of stuff that's supposed to be obsolete, that should not be used, that is deprecated, etc. I presume Walter thinks that the problems caused from keeping it and from unwanted usages of it, is smaller than the breaking troubles caused by removing it. I am person that likes to keeps things ordered and clean, so I prefer to remove old stuff after a suitable deprecation period, instead of keeping it around almost forever (like floating point special comparison operators). Bye, bearophile
Jul 10 2013
On Monday, July 01, 2013 18:32:30 CJS wrote:Is there some header/module that includes declaration for all C standard libraries? I'm wondering both in general for future reference, and for the specific case of wanting to time a function and not knowing 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.If you want to time a function, checkout std.datetime.StopWatch: http://dlang.org/phobos/std_datetime.html#StopWatch As for C standard library functions in general, as Adam pointed out, they're in the in the core.stdc.* modules. - Jonathan M Davis
Jul 01 2013
On Monday, 1 July 2013 at 18:09:32 UTC, Jonathan M Davis wrote:On Monday, July 01, 2013 18:32:30 CJS wrote:+1 I really came to hate c's clock, StopWatch has been much more pleasant experience to work with.Is there some header/module that includes declaration for all C standard libraries? I'm wondering both in general for future reference, and for the specific case of wanting to time a function and not knowing 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.If you want to time a function, checkout std.datetime.StopWatch: http://dlang.org/phobos/std_datetime.html#StopWatch
Jul 02 2013