4 ms·
> If you know why our macOS users use _main I'd love to know. You'll find this on Linux, too. You'll notice the compiler (on POSIX systems?) prefixes your symb
by delinka 7y ago
> If you know why our macOS users use _main I'd love to know.
You'll find this on Linux, too. You'll notice the compiler (on POSIX systems?) prefixes your symbol names with _ since The Dawn Of Time.
- CalChris 7y agoThe leading underscore on MacOS is part of the Mach-O standard [1]. This was inherited from a.out which really wasn't much of a standard per se but rather just a collection of a.out implementations [2]. Mach-O (1987) predated ELF (1993) and the later ELF abandoned the underscore as unnecessary. [1] http://math-atlas.sourceforge.net/devel/assembly/MachORuntime.pdf http://math-atlas.sourceforge.net/devel/assembly/MachORuntim... [2] https://www.nasm.us/doc/nasmdoc9.html https://www.nasm.us/doc/nasmdoc9.html
- daeken 7y agoIt actually doesn't prefix all symbol names as such! The underscore prefix indicates the cdecl calling convention specifically; other calling conventions have their own name mangling schemes. Edit: I had a nagging feeling that I was forgetting something, and I was. This is only a Windows convention, not a more universal thing.
- Vogtinator 7y agoI've never seen this on Linux. There is a gcc option -fleading-underscore, which is meant for "legacy assembly code".