I am taking a Linux point of view below.
The main
function is very special in the standard definition (for hosted C11 implementations). It is also explicitly known by recent compilers (both GCC & Clang/LLVM....) which have specific code to handle main
(and to give you this warning). BTW, GCC (with help from GNU libc headers thru function attributes) has also special code for printf
. And you could add your own customization to GCC using MELT for your own function attributes.
For the linker, main
is often a usual symbol, but it is called from crt0 (compile your code using gcc -v
to understand what that really means). BTW, the ld(1) linker (and ELF files, e.g. executables or object files) has no notion of types or function signatures and deals only with names (This is why C++ compilers do some name mangling).
And the ABI and the calling conventions are so defined that passing unused arguments to a function (like main
or even open(2)...) does not do any harm (several arguments get passed in registers). Read the x86-64 System V ABI for details.
See also the references in this answer.
At last, you really should practically define your main
as int main(int argc, char**argv)
and nothing else, and you hopefully should handle program arguments thru them (at least --help
& --version
as mandated by GNU coding standards). On Linux, I hate programs (and I curse their programmers) not doing that (so please handle --help
& --version
).