iTranslated by AI
Why Does MinGW's gcc Default to a.exe?
TL;DR
Because the default output filename for gcc when the -o option (which specifies the output filename) is missing is a.out, and for MinGW, which is the Windows port of gcc, the default output is a.exe.
Background of the Investigation
A junior colleague was studying C++ using Visual Studio Code on Windows. I noticed they were debugging with an output filename named a.exe and wondered, "What kind of junk name is that? Where is that being specified?" However, I couldn't find any such specification anywhere. When I looked into it, I found out that it was simply the default for gcc.
Also, a file named hoge.o was being generated during compilation. My colleague tried to open hoge.o in a text editor and said, "I can't fix the garbled text!" I couldn't immediately give a precise technical reason for why that wasn't a file meant to be opened in an editor. Upon checking the reference below, I learned that hoge.o is an object file (equivalent to .obj in C#, etc.), so that was a good learning experience for me.
References
3.2 Options Controlling the Kind of Output - GCC online documentation
Note: This is unrelated to the main topic, but the GCC online documentation is so hard to read... It might not be intended to be viewed as a raw HTML version, but still. I finally reached the target location by using Google Search's site specification option like "a.out" site:gcc.gnu.org/onlinedocs.
Discussion