On 09.10.2014 15:31, Jacob Carlborg wrote:
On 09/10/14 08:43, Rainer Schuetze wrote:
Yes, but the problem is not to access command line arguments, but to run
code before the GC initialization i.e. before _d_run_main is executed.
If we can assume a C++ backend, using static initialization of a C++
global could work:
static bool initGC = configureGC();
because the C++ runtime runs configureGC before calling C main. I'd
rather like to see a solution using D, though.
It's enough with a C function with __attribute__((constructor)). This
will run before C main.
This is a gcc extension, which isn't supported under Windows by dmd. Can
you add this attribute in GDC/LDC as part of a D file aswell?
I recently made some experiments with pragma(data_seg,"SEGMENT_NAME") or
pragma(code_seg,"SEGMENT_NAME") that could also be used to move
something into the initializer section of the runtime. For COFF it kind
of works, but unfortunately there is no way to tell OMF to put a COMDAT
(needed for templates) into a specific segment.