Re:Main is usually a function, so when is it not? (2015)
by detaro on Sunday September 10, 2017 @10:20AM
(#15212309)
MSVC doesn't claim to implement C99, where this rule was added, so it kind of makes sense that it doesn't happen. (generally, if they added C99-stuff then only where it was required for C++)
[ Parent
| on HN ]
Re:Main is usually a function, so when is it not? (2015)
by user5994461 on Sunday September 10, 2017 @10:42AM
(#15212395)
int main(void)
{
__asm {
mov eax, 123
}
}
// visual studio command line
// cl testc.c
// cl testcpp.cpp
// testc.exe
// echo C %errorlevel%
// testcpp.exe
// echo CPP %errorlevel%
Indeed. It's a C99 thing.For those not familiar with MSVC. The C compiler is not C99 compliant and the C++ compiler is.
Re:Main is usually a function, so when is it not? (2015)
by 1_2__4 on Sunday September 10, 2017 @11:32AM
(#15212624)
I love C but this whole thread highlights a lot of the criticism of it. Everyone's right based on some standard or switch, and everyone's wrong for the same reason.
Re:Main is usually a function, so when is it not? (2015)
by jstimpfle on Sunday September 10, 2017 @01:51PM
(#15213333)
This is not specific to C, but common to all evolving standards. If you want portable code just drive on the middle of the road.
Often this is as easy as coding to an older standard, like C89 with a few selected features from later standards, and adding some compatibility features / problem detection in the build system.
And don't rely on features that are difficult to explain and/or add only questionable value. Just return 0 from main, it's the obvious simple thing to do.