digitalmars.D.learn - Why does file order matters when using -run option?
- Marc (9/21) Mar 14 2018 myModule.d
- Adam D. Ruppe (14/16) Mar 14 2018 Check the help text:
- Seb (10/32) Mar 14 2018 Not even that dmd mymodule.d -run app.d works and dmd -i -run
assume the files: app.dvoid main() { import myModule : foo; writeln(foo(...)); }myModule.d module myModule;int foo(int n) { .... }the following fail:dmd -run app.d mymodule.dgive error like this:Error: module `myModule` is in file 'myModule.d' which cannot be readbut this doesn't fail:dmd app.d mymodule.d && appWhy does -run fail here? I thought it was a shorthand to this batch:dmd app.d mymodule.d app.exe del app.exe
Mar 14 2018
On Wednesday, 14 March 2018 at 14:44:24 UTC, Marc wrote:Why does -run fail here? I thought it was a shorthand to this batch:Check the help text: $ dmd -h dmd [<option>...] -run <file> [<arg>...] <arg> Argument to pass when running the resulting program Notice that there's only one file there. Everything after it is passed as args to the resulting program. So dmd -run cannot support multiple D files. Though, with the new `-i` option you might be able to get it to infer modules. dmd -i -run file_with_main.d args_to_main....... and if it can locate the other modules automatically it should bring them in there.
Mar 14 2018
On Wednesday, 14 March 2018 at 14:44:24 UTC, Marc wrote:assume the files: app.dNot even that dmd mymodule.d -run app.d works and dmd -i -run app.d works too. However, at the moment -run needs to be the last parameter. That's a more or less arbitrary restriction. And no one has lifted it (yet). Though there's a bit of work on that front: https://github.com/dlang/dmd/pull/7927 The main problem is that the arguments after -run module are passed to the program and thus -run can be ambiguous.void main() { import myModule : foo; writeln(foo(...)); }myModule.d module myModule;int foo(int n) { .... }the following fail:dmd -run app.d mymodule.dgive error like this:Error: module `myModule` is in file 'myModule.d' which cannot be readbut this doesn't fail:dmd app.d mymodule.d && appWhy does -run fail here? I thought it was a shorthand to this batch:dmd app.d mymodule.d app.exe del app.exe
Mar 14 2018