| |
| Posted by Vladimir Panteleev in reply to ryuukk_ | PermalinkReply |
|
Vladimir Panteleev
Posted in reply to ryuukk_
| On Friday, 3 March 2023 at 01:21:52 UTC, ryuukk_ wrote:
> I have some questions:
- why does it work with LDC?
- why does it work with DMD when build/link in 2 step?
- why it doesn't work when DMD is invoked once for build/link
I think these are probably coincidences and the answer can be summarized as "that's what ends up happening due to the details of the implementation".
>
- is this a bug in DMD or my code is wrong?
I would say the code is wrong in principle, though as you've noted it can still work in some specific circumstances.
>
- if it's wrong, then why does it compile/no error?
extern(C) main is a low-level feature, because it effectively turns off parts of the language. However, the rest of the program doesn't know that this is the case - currently the compiler simply assumes you know what you're doing. Maybe it's not OK that it's easy to use it by accident.
|