Question regarding D v.0110

Steven Schveighoffer schveiguy at gmail.com
Sun Jul 12 16:33:19 UTC 2020


On 7/12/20 10:19 AM, Adam D. Ruppe wrote:
> On Sunday, 12 July 2020 at 08:18:00 UTC, Remi wrote:
>> I just forced it to always use extern(Windows) for now until I need to 
>> make it work across platforms.
> 
> Use `extern(System)` in that case - it will be extern(Windows) and 
> windows and extern(C) elsewhere. Common enough case to be built into D.
> 
>> Good news! Finally got a .exe and it seems to start running, but it 
>> has now detected a cyclic dependency between constructors/destructors. 
>> Time to dive more into the code itself!
> 
> You can disable that cycle check by just adding this global declaration 
> somewhere to the file with the main function:
> 
> ```
> // enable cycles in static ctors
> extern(C) __gshared string[] rt_options = ["oncycle=ignore"];
> ```
> 
> Then you can probably get it actually going!

It's probably not going to be bad, but it can be. If it finds a cycle, 
it can't actually sort the ctors. This means that things could be run 
out of order, and if one static value depends on another, then you could 
have bad things happen.

However, most static ctors don't really depend on other static data, so 
in that case, it would be fine.

Another option to try is "oncycle=deprecate", which uses the old 
algorithm that was flawed.

I should say though that the old algorithm, even though "old" may not be 
as old as the game, which means it still might not work right.

Also, the old flawed algorithm changes the order of construction 
sometimes based on the order modules are passed to the compiler (hence 
the "flawed" part of it).

Good luck!

-Steve


More information about the Digitalmars-d mailing list