digitalmars.D.bugs - [Issue 9723] New: add missing main() when compiling exe with -unittest
- d-bugmail puremagic.com (20/20) Mar 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (25/25) Mar 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (8/8) Mar 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (10/12) Mar 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (9/18) Mar 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (8/8) Mar 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (13/13) Mar 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (7/10) Mar 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (7/8) Mar 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (8/9) Mar 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (9/9) Mar 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (11/11) Mar 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (7/7) Mar 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (11/11) Mar 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (8/10) Mar 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (8/14) Mar 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (10/10) Mar 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (11/11) Mar 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (6/6) Mar 16 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (11/11) Mar 16 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (9/9) Mar 16 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
- d-bugmail puremagic.com (12/12) Apr 12 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9723
http://d.puremagic.com/issues/show_bug.cgi?id=9723 Summary: add missing main() when compiling exe with -unittest Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bugzilla digitalmars.com 14:32:08 PDT --- When compiling a module with -unittest, and an exe file is being generated, and there is no main() function, add: int main() { return 0; } and compile it in. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 14:55:25 PDT --- How can you reasonably implement this if you pass object files or static libraries to DMD which might contain main? E.g.: foo.d: import bar; void main() { } bar.d: unittest { assert(0); } $ dmd -c foo.d $ dmd -unittest -ofbar.exe foo.d bar.obj You could end up getting linker errors if DMD tries to add another main function. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 16:59:40 PDT --- Good point. You can deal with it by not doing it if there are any explicit .o files on the command line. No need to worry about libraries with main() in it - nothing to pull it in. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 17:02:11 PDT ---No need to worry about libraries with main() in it - nothing to pull it in.What do you mean by that? Also we have --main in RDMD that is used exactly for this purpose. Why not just move this switch over to DMD instead of doing magic that stops working as soon as you add separately-compiled dependencies? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 17:03:12 PDT ---Also, by doing it as a switch we can keep compatibility with RDMD, all it has to do is call DMD's -main switch instead of making a separate file with main in it. So old code continues to work. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------No need to worry about libraries with main() in it - nothing to pull it in.What do you mean by that? Also we have --main in RDMD that is used exactly for this purpose. Why not just move this switch over to DMD instead of doing magic that stops working as soon as you add separately-compiled dependencies?
Mar 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 17:39:32 PDT --- I mean that if you've installed main() in a library file, it won't get pulled in unless you have a reference to main somewhere else, which is awfully unlikely and I've never seen it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 Vladimir Panteleev <thecybershadow gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thecybershadow gmail.com 02:49:04 EET --- Some libraries define main(), and let the user define their own entry point. E.g. libfoo could have a foomain() declaration, and the user has to implement it. I believe SDL is one library that does this. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 02:50:13 EET ---I mean that if you've installed main() in a library file, it won't get pulled in unless you have a reference to main somewhere else, which is awfully unlikely and I've never seen it.Doesn't the C runtime have a reference to main()? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 18:01:12 PDT ---Doesn't the C runtime have a reference to main()?No. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 18:04:34 PDT ---Some libraries define main(), and let the user define their own entry point.Even if there are some, the workaround is pretty easy - just add a module, any module, in .o form to the command line. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 03:04:56 EET --- Oh, sorry, I meant for C programs. main() isn't the entry point, not on Windows at least, so there has to be some initialization code that invokes it. For D, it's in Druntime, and it uses the C main as an "entry point". On Windows the C runtime defines WinMain, which initializes and calls the C main(). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 hsteoh quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hsteoh quickfur.ath.cx Can't we just make the DMD-injected empty main() a weak symbol, so that it gets overridden if main is already declared anywhere else? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 13:57:22 PDT --- You guyz make a good case. I amend my proposal so this should happen only when a "-main" switch is thrown on the command line. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 jens.k.mueller gmx.de changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jens.k.mueller gmx.de Why is rdmd --main not good enough? I find this enhancement adds very little value. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 15:14:22 PDT ---You guyz make a good case. I amend my proposal so this should happen only when a "-main" switch is thrown on the command line.Ok good. One other question: If another main() is found while -main is used, should the compiler error or just avoid generating main() on its own? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 16:52:19 PDT ---Disregard this question, there's already a check in DMD for multiple main functions, it will be very useful. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------You guyz make a good case. I amend my proposal so this should happen only when a "-main" switch is thrown on the command line.Ok good. One other question: If another main() is found while -main is used, should the compiler error or just avoid generating main() on its own?
Mar 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull 17:53:21 PDT --- https://github.com/D-Programming-Language/dmd/pull/1751 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|pull | AssignedTo|andrej.mitrovich gmail.com |nobody puremagic.com 21:28:21 PDT --- I'll let someone else work on this. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 00:55:55 PDT --- https://github.com/D-Programming-Language/dmd/pull/1753 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 16 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/1eb44f54ac12ff747ab447be06e1fe430ffe77a9 fix Issue 9723 - add missing main() when compiling exe with -unittest https://github.com/D-Programming-Language/dmd/commit/a8fd11928e436d63936542576527759b488b3f4f fix Issue 9723 - add missing main() when compiling exe with -unittest -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 16 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 16 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9723 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|add missing main() when |Implement -main switch to |compiling exe with |inject a default main() |-unittest |function 10:08:29 PDT --- Renamed title for changelog. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 12 2013