Very simple (bug/misfeature/feature)?

Martin v. Loewis martin@mira.isdn.cs.tu-berlin.de
Sat May 1 01:41:00 GMT 1999


> Is this a bug, or are there legitimate reasons why one might
> wish to do this?

Neither, nor. The behaviour of the -o option is very straight-forward,
and well-documented. In addition, it has a very long tradition - it
was already explained in the first books about C.

There are legitimate reasons why -o should overwrite existing files:
If you recompile a program again and again, you don't always want to
remove the object file.

There are also legitimate reasons why you can give arbitrary file
names to object files. For example, when keeping object files compiled
with different options simultaneously, using different extensions is a
common approach.

Finally, there is a good reason why the compiler doesn't try to detect
whether the output file is the same as the input file: That can't be
done, in general, for arbitrary operation systems. There are many ways
to produce name aliases, which can't be detected easily:

  cc -o mytest.c ../src/mytest.c # should this work or not
  ln -s mytest.c bla
  cc -o bla mytest.c             # what about this?

Hope this helps,
Martin


More information about the Gcc-bugs mailing list