gcc merrily compiles empty files
Tue Jun 20 16:32:00 GMT 2000
On Tue, Jun 20, 2000 at 07:17:27PM -0400, Henry Sobotka wrote:
> On OS/2, both gcc 2.81 and pgcc 2.95.2 will compile a zero-length
> hello.c with the -c flag without the slightest warning or failure. Some
> sort of output on that condition would seem appropriate. It's not a
> problem compiling an executable, because the missing main() causes a
> failure. I came across the behavior in encountering massive linkage
> barf, which I tracked down to an empty .cpp file that had somehow gotten
> created in an object directory, and was being compiled instead of the
> real source. "Nothing to do." + exit or at least an "Empty source file"
> might spare others a few hairs or headaches when this type of accident
The -pedantic option warns about this (of course, it warns about lots of other
things as well). Speaking as a programmer, I can certainly imagine uses for
empty files (for example for conditional debug code).
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work: email@example.com phone: +1 978-486-9304
Non-work: firstname.lastname@example.org fax: +1 978-692-4482
More information about the Gcc-bugs