Main in Cpp File
Kye
Posts: 2,200
I've noticed that when compiling a .cpp file or a .cogcpp file propeller-elf-g++ enforces main must return an int. Is this because of the -std=gnu++0x flag? The -std=c99 used for the gcc (not g++) doesn't have issues with a void main taking any argument type.
Comments
This gives an error even without get the -std=gnu++0x flag if a I specify that main returns void. I have no idea what the default C++ standard is for my g++ on Debian.
However if I don't put any return type on main() then it compiles OK as the default return type is int.
Similarly clang++ gives an error if the return type is not int.
Even better it gives an error if you don't specify a return type, for example:
hello.cpp:4:2: error: C++ requires a type specifier for all declarations.
Bottom line is that C and C++ are different languages with different standards and standards bodies.