nothrow function callbacks in extern(C) code - solution

via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 23 02:32:13 PDT 2014


On Sunday, 22 June 2014 at 08:43:20 UTC, Rainer Schuetze wrote:
> On 22.06.2014 02:23, Andrei Alexandrescu wrote:
>> Callbacks passed into OS/clib functions are never supposed to 
>> throw so
>> we must annotate them all with nothrow. C functions are never 
>> designed
>> under the assumption callbacks may throw. -- Andrei
>
> For nothrow that restriction makes sense, though there are 
> functions in the Windows "C API" that actually may throw, e.g. 
> HeapAlloc [1] and MmProbeAndLockPages [2]. No callbacks are 
> involved in these examples, though.
> Under unix, signal handlers that throw exceptions seem to be 
> used, though this might be non-standard. We even have one in 
> druntime [3].

The SEGV handles throws Errors, not Exceptions, it's ok to be 
nothrow.


More information about the Digitalmars-d mailing list