just stop program

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Sun Nov 7 02:42:44 PST 2010

On Fri, 05 Nov 2010 15:09:05 +0000, div0 wrote:

> On 05/11/2010 10:14, Lars T. Kyllingstad wrote:
>> On Fri, 05 Nov 2010 09:47:37 +0000, div0 wrote:
>>> On 05/11/2010 09:32, spir wrote:
>>>> Hello,
>>>> Is there a way for a program to simply exit before end of main()? An
>>>> instruction like exit, quit, end, halt, stop...
>>>> [assert(false) is not why I'm looking for, as (1) the compiler
>>>> protests if there is unreachable code (2) it throws in non-release
>>>> mode. I just want the program to stop, basta! My use case is first
>>>> debugging (avoid later debug output to be written on terminal).]
>>>> Denis
>>>> -- -- -- -- -- -- --
>>>> vit esse estrany ☣
>>>> spir.wikidot.com
>>> import std.c.process
>>> then you've exit(int)&  abort()
>>> You can get access to most C library functions through std.c.*, so
>>> it's always worth a quick check in there for lower level stuff.
>> In D2 it is generally preferable to import core.stdc.* to get at the C
>> stuff.  std.c.* is a relic from D1, and it is uncertain what will be
>> kept in the library.
>> In this case, import core.stdc.stdlib to gain access to exit(int) and
>> abort().
>> -Lars
> Since when?

I don't know, I just remember there was a discussion about it -- probably 
on the Phobos mailing list.  Or it could be my own opinion seeping 
through, you never know. ;)

The thing is, the C stdlib is needed in druntime, therefore the headers 
need to be in druntime.  And it's pointless to have them in two places, 
therefore they should be removed from Phobos.  (std.c could arguably be 
kept for non-standard functions.)

In D1, the runtime and the standard library weren't separated, and it 
thus made sense to have the C headers in std as well.

> That's not mentioned anywhere in the phobos docs and none of the core.*
> modules are even listed.

No, and I agree they should at least be listed.


More information about the Digitalmars-d-learn mailing list