views:

539

answers:

4

Most UNIX C compilers link executables by default to a file called "a.out". Why? Is this a written standard or just de-facto standard behavior? What would break if these compilers would just produce an error message (or use a different default name) instead of producing "a.out"?

+4  A: 

a.out

RaYell
+2  A: 

A.out is actually the name of an UNIX executable file format. (ELF is another)

The compiler produces that name (by tradition) if you don't give your executable a name explicitly.

What would break if these compilers would just error out instead of producing "a.out"?

Nothing would break, but what do you mean by 'error out'? Do you mean, refuse to compile unless an executable name is supplied to the linker ?

David Toso
+15  A: 

a.out stands for assembler output.
I think that justifies why most compilers have this name as default. More info here.

Neeraj
a.out is also the name of the executable format. Makes for a nice handy 8.3 filename too though.
Matthew Scharley
+1  A: 

wont be it better if the compiler produced the output file with the same name as the source file with a .out extension? Say we have a source file named abc.c. The compiler would generate abc.i, abc.s, abc.o in subsequent stages of preprocessing, assembling and compilation respectively. Thus the default output file could be easily abc.out.

What made the creators of gcc not to use this file name? I hope there must be a good reason for this.

Sudhanshu