ARM Cortex-M Microcontroller startup files
Johannes Pfau via Digitalmars-d
digitalmars-d at puremagic.com
Fri May 1 00:34:03 PDT 2015
Am Fri, 01 May 2015 06:57:07 +0000
schrieb "Timo Sintonen" <t.sintonen at luukku.com>:
> I think we should omit moduleinfo totally and so we can not have
> module constructors. I think pointers to static constructors are
> available in a certain section that I have not in my link script.
> Adding this section should make them available.
C-like constructors. I've got some old code which allows attaching a
@attribute("cctor") to a extern(C) function to make it a C-constructor.
That code could be revived quickly if it's useful.
Outputting normal D module ctors as C-ctors is possible but 'hacky':
First, the calling convention doesn't match. In order to be compatible
C-constructors should stay extern(C). Now extern(D/C) are actually the
same for all GDC supported architectures, but still. There's also the
issue that it's a semantic change as you can no longer rely on cycle
detection.
TLDR: I'd prefer using @cctor extern(C) void foo() {} instead of normal
d module ctors.
Bonus points: You can have more than one @cctor per module.
More information about the Digitalmars-d
mailing list