ldc-developers/ldc — pull request #161 by redstar (2012-09-12 16:19:53+00:00)
Title: Add pragma to install function as global ctor or dtor.

DMD has the obscure functionality to install functions starting with `_STI_` as global ctors and funtions starting with `_STD_` as global dtors. IMHO a pragma is a better way to specify the behaviour.

This commit adds pragma(ctor) and pragma(dtor). If the pragma is specified on a function or static method then an entry is made in the corresponding list. E.g. in `monitor_.d`:

extern (C) {
#pragma(ctor)
void _STI_monitor_staticctor()
{
// ...
}
}

This works on Linux without problems. On Windows with MS C Runtime only ctors works due to a bug in LLVM.