[Issue 16440] wrong code with -main -c -of

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Aug 28 07:18:17 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16440

Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |accepts-invalid
                 CC|                            |andrej.mitrovich at gmail.com
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> ---
The problem is the compiler allows -c and -main. It will generate the D main
function in a separate module but later when you try to link via `dmd test.obj`
you won't be linking with this module.

The workaround is simple, pass -main while linking:

-----
dmd -c -oftest.o -unittest test.d
dmd -main test.o
./test
-----

In the meantime allowing -c and -main in the same invocation should be
disallowed.

--


More information about the Digitalmars-d-bugs mailing list