C main function

This cluster centers on debates about the proper signature, return type, and standards compliance of the main() function in C programs, including void main(), implicit returns, entry points, and freestanding environments.

📉 Falling 0.4x Programming Languages
937
Comments
19
Years Active
5
Top Authors
#6762
Topic ID

Activity Over Time

2008
6
2009
9
2010
32
2011
35
2012
26
2013
51
2014
43
2015
43
2016
33
2017
66
2018
54
2019
49
2020
111
2021
60
2022
82
2023
87
2024
80
2025
64
2026
6

Keywords

UB THE github.io microsoft.com m.c function.html short.o O0 SDK bitbucket.org main void function 00 int code parameter program constructor short

Sample Comments

monochromatic • Sep 10, 2017 • View on HN

Is it undefined behavior to have main be anything other than a function that returns int?

holy_city • Jun 23, 2019 • View on HN

That kind of assumes you have a main() function.

morganwilde • Nov 16, 2013 • View on HN

Are you trying to dispute the fact that `main()` is THE entry point for any C program? I'd be interested in hearing a more comprehensive explanation.

shawxe • May 13, 2019 • View on HN

Why not just use int main(void)?

city41 • Jan 12, 2010 • View on HN

Ah, I guess it's just main that implicitly returns 0.

scintill76 • Jun 14, 2021 • View on HN

You could make main() a standard C function that merely calls this machine code hack function.

selimthegrim • May 13, 2019 • View on HN

Ah, the days of void main(void)

derleth • Mar 14, 2011 • View on HN

Anything that has 'void main' isn't quite up to snuff, to begin with.

signa11 • Sep 10, 2018 • View on HN

on similar lines, i find this http://jroweboy.github.io/c/asm/2015/01/26/when-is-main-not-... quite entertaining !

to3m • Sep 25, 2017 • View on HN

The function called at program startup is named main, which this translation unit defines. No other may therefore define it. Binaries that don't run main are out of the scope of the standard, and so irrelevant to the discussion.Anyway, as a more general point: your argument is, basically, "the customer is wrong". But the customer is never wrong! Therefore your argument is invalid.