error: ISO C++ forbids declaration of `__nomain' with no type -
i have simple c++ program here:
#include <iostream> using namespace std; main () //no return type main. yet program compiles , runs ok { //when run itself. cout << "hi"; }
but program no longer compiles if add blank unit test in file called newsimpletest1.cpp
:
#include <stdlib.h> #include <iostream> int main(int argc, char** argv) { }
if run it, compiles , prints "hi" expected. if test project error:
error: iso c++ forbids declaration of `__nomain' no type
when add return type 'int' 'main', compiles , runs correctly. i'm trying figure out error trying tell me.
i'm using windows xp compiling netbeans 7.1.2 using default g++ compiler.
it says, in hosted environment, main
should have type. quote c++ standard 3.6.1, paragraph 2
an implementation shall not predefine
main
function. function shall not overloaded. shall have return type of typeint
, otherwise type implementation-defined. implementations shall allow both — function of () returningint
, — function of (int, pointer pointer char) returningint
type ofmain
(8.3.5).
Comments
Post a Comment