Why does the following program write the message 'Foo' twice?

Vladimir Panteleev vladimir at thecybershadow.net
Wed Mar 19 03:10:17 PDT 2014


On Wednesday, 19 March 2014 at 10:08:50 UTC, Gary Willoughby 
wrote:
> Why does the following program write the message 'Foo' twice?
>
> void main(string[] args)
> {
> 	pragma(msg, "Foo");
> }

The message is not printed by the program, but by the compiler.

If you build the program via dmd, the message is only printed 
once.

If you use rdmd, it will be printed twice, because rdmd invokes 
dmd once to gather the program's dependencies, and a second time 
to actually build the program.


More information about the Digitalmars-d-learn mailing list