www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Compile an empty source file

reply Russell Wilkins <russell.wilkins grovestarsoftware.com> writes:
v0.119 windows

I quite by accident found you can compile a completely empty source file and
get 
  both an obj and an exe (which does nothing but runs without error). I think 
the compiler should error if no code has been generated.

Russell
Mar 24 2005
parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Russell Wilkins wrote:
 v0.119 windows
 
 I quite by accident found you can compile a completely empty source file 
 and get  both an obj and an exe (which does nothing but runs without 
 error).
Congratulations, you've written the shortest ever D quine!
 I think the compiler should error if no code has been generated.
Not sure about this. Do you mean the compiler or the linker? I can see a few legit reasons for a module having no code generated: - it's a module entirely of import statements, function prototypes, struct definitions, type aliases, symbolic constants, whatever else.... - it's a module that's only needed for certain platforms/editions/whatever, and so all the code may be versioned out (if that follows). OTOH, the linker ought to error, since there is no main function. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Apr 05 2005