rdmd vs dmd WRT static constructors

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 8 20:11:17 PDT 2017


On Sunday, 9 July 2017 at 02:57:54 UTC, Andrew Edwards wrote:

>
> $ rdmd statmain.d stat1.d stat2.d
> // outputs nothing...
>
>
> Bug or intended behaviour?
>

rdmd takes the first D file you give it, follows its import tree, 
and compiles all the modules found there. Anything on the command 
line after the first source file is treated as a command line 
argument to the generated program. So stat1.d and stat2.d are 
never compiled. You'll see if you modify your main function to 
output the args that it will print the file names you passed.

To include stat1.d and stat2.d in the compilation, you'll either 
have to import them in statmain.d or use the --extra-file command 
line switch:

rdmd --extra-file=stat1.d --extra-file=stat2.d statmain.d


More information about the Digitalmars-d-learn mailing list