WinAPI callbacks and GC

evilrat evilrat666 at gmail.com
Tue Apr 23 20:38:04 PDT 2013


On Tuesday, 23 April 2013 at 21:21:28 UTC, Jack Applegame wrote:

> If not, how to make it safe? I'm trying call 
> thread_attachThis() at the beginning of CtrlHandler fucntion, 
> but it doesn't compile because thread_attachThis() is not 
> nothrow.

what stops you from calling normal functions in nothrow one? use 
try-catch inside nothrow. nothrow means that function doesn't 
throw, not it can call only nothrow.

also if another func is C language func, you may try to add 
nothrow to it's signature since it's anyway can't throw anything.

-------------------
example:

void doWithThrow()
{
int x = 1;
x++;
}

nothrow void doStuff()
{
try {
doWithThrow();
}
catch ( Exception e )
{
// your handling code here...
}
}

void main()
{
doStuff();
}
-------------------


i hope i don't learn people to do bad or stupid things :(


More information about the Digitalmars-d-learn mailing list