Some problems of main function disassembly in C language

problem description

I use the CLion tool to view the disassembly code of C language, as shown in figure
Mac
int a = 100;4

:Mac OS
:CLion
mainmovl $0x0 -0x4(%rbp)

movl $0x0 -0x4(%rbp)return 0;return 0;return 1;

Apr.18,2022

is to store the default return value of 0 in the register


earlier, I found an explanation on the Internet, but I was not satisfied, so I searched for it and found the basic knowledge, and I thought it might be relevant:
what is the difference between the http://www.runoob.com/note/26656
C language int main () and int main (void)?

/ / this is correct
int main ()
{
if (0) main (42);
}

/ / this causes errors
int main (void)
{
if (0) main (42);
}

if int main () can be entered as a parameter, then memory must be allocated.
is there any difference in int main (void)? Sorry, it's not convenient for me right now. Try it yourself

Menu