www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5573] New: Compiler (not linker) should generate an error for missing main()

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5573

           Summary: Compiler (not linker) should generate an error for
                    missing main()
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: clugdbug yahoo.com.au



The standard linker error is (a) newbie-hostile; and 
(b) on Windows, it generates an invalid executable. Running this executable
seems to cause an infinite loop you cannot break out of.

As Walter said on the newsgroup, it's not possible to solve this in general:
 The problem is the main() can come from a library, or some other .obj 
 file handed to the compiler that the compiler doesn't look inside. It's 
 a very flexible way to build things, and trying to impose more order on 
 that will surely wind up with complaints from some developers.
But, it's only the trivial case that matters. The compiler should generate an error if all files passed to the compiler are .d/.di files, and there is no use of pragma(lib). Error can be something like: "No main function, and no .obj or .lib file which could contain one". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 14 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5573


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



See also bug 5215, bug 4680

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5573


Robert Clipsham <robert octarineparrot.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |robert octarineparrot.com



21:03:52 GMT ---
Another possibility for this (and other linker errors) - given that dmd invokes
the linker, its stderr could be redirected and filtered. The compiler can then
give a nice error for a missing main() function, and also demangle symbol names
without the linker needing modification. This avoids the issue of main() being
in a library, but is also a bit more hacky.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5573


Borden Rhodes <incoming-only bordenrhodes.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |incoming-only bordenrhodes.
                   |                            |com



18:23:09 PDT ---
I agree that the emphasis should be on clarity of the error message rather than
trying to out-think the programmer. The linker dump, to uninitiated noobs like
me, looks an awful lot like a seg fault or bug with the compiler, not a flaw in
the programmer.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 28 2012