Open cpiber opened 3 years ago
This will not be valid C++. In the C++ standard, the standard mandates that the return type must be int. Compile it with -Wall
or pedantic
and you will receive this: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
.
As for C, the standard allows implementation defined main functions, but I think we should still stick to the ones that are required by the standard, since these are meant to be c/cpp files and not files for gcc/g++.
Actually I don't think warnings are an issue, at least one of the C-family programs also only worked with warnings (been a while since I tested). Or is it only those that specifically violate the standard?
In c and cpp, no return type defaults to
int
.g++ does not complain at all about this (cpp).
gcc gives a warning (
type defaults to ‘int’ in declaration of ‘main’ [-Wimplicit-int]
), is this allowed? (c)