Yeah.. I've noticed..
even with the -ansi flag or worse yet -std=gnu89
I allways thought an empty main() was only allowed in C++
/me looks for his "A Book on C" and "C++ for C programmers" books..
Printable View
Yeah.. I've noticed..
even with the -ansi flag or worse yet -std=gnu89
I allways thought an empty main() was only allowed in C++
/me looks for his "A Book on C" and "C++ for C programmers" books..
Since C is just a subset of the C++ language, it's correct to call it C++. Even though C is an older language than C++, it doesn't mean it won't compile in a C++ compiler.
That's actually what C++ means... It's C plus some additional functionality.
Main isn't empty. It's defined to return an int.. int main() {...}.Quote:
Originally posted here by the_JinX
Yeah.. I've noticed..
even with the -ansi flag or worse yet -std=gnu89
I allways thought an empty main() was only allowed in C++
IIRC it's correct to define an empty (void) parameter list.
http://www.comeaucomputing.com/techtalk/#voidmain
Actually C++ is a superset of C. ;)Quote:
Since C is just a subset of the C++ language
cheers,
catch
PS. Please don't both to neg me with "wah! supersets must contain subsets!" I was being facetious.
The code is ANSI C :) Yes, ANSI, you're allowed to declare main() like that in ANSI C but not in C++. The includes for C++ usually don't keep the .h suffix.
In terms of warnings I'd append -Wall to my flags as a general good practice.