help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: g++ flag?


From: Default User
Subject: Re: g++ flag?
Date: Thu, 13 May 2004 16:06:15 GMT

Abhisek Sinha wrote:

> Earlier compilers used to take the default return type of any function
> to be int.
> g++, in this case where ther is no return type specified gives error
> as
> error: ISO C++ forbids declaration of `main' with no type

That is correct, it's illegal.

> can this be disabled using any g++ flag in 3.3.3

Why not just fix the problem instead of trying to cover it up? Usually
these things can be dealt with with a few hours of effort, then it's
done and portable forever. Even if you find a flag that allows it, a new
release might remove it and the code would not be portable to other
compilers.
 
> It is to be noted that gcc(3.3.2) does not throw any any error even if
> there is no return type.
> Not even with -ansi and -pedantic flag

gcc is a C compiler and not a C++ compiler.

> Can somebody tell, is gcc not strictly adhering to ISO C++ standard?

The C89 standard provide for default return values. The latest standard
is in line with C++ and forbids it. 



Brian Rodenborn


reply via email to

[Prev in Thread] Current Thread [Next in Thread]