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

Re: GCC



On Tue, Feb 17, 2004 at 12:02:26PM -0300, Xavier Andrade wrote:
> 
> On Tue, 17 Feb 2004, Werner Mahr wrote:
> 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Am Dienstag, 17. Februar 2004 06:27 schrieb Mike M:
> >
> > > main()
> > > test.cpp:4: warning: ISO C++ forbids declaration of `main' with no type
> >
> > void main(void) and you have a type.
> >
> 
> In C++ functions that don't take arguments are f() and not f(void).

In declarations I use f(void).  When invoking, I use f().

The discussion of declaring main is  off the point though.  The example
is to show that the C++ compilers weren't complaining about the .h on the
#includes.

ON my stable machine, I have g++ 3.0 loaded.  In 
/usr/include/g++-3/iostream the following contents are found:

---------iostream----------------
// -*- C++ -*- forwarding header.
// This file is part of the GNU ANSI C++ Library.

#ifndef __IOSTREAM__
#define __IOSTREAM__
#include <iostream.h>
#endif
---------------------------------

The __IOSTREAM__ is defined which identifies your code as using
iostream instead of iostream.h.  The compilers don't seem to care but I 
know I've seen a nastygram about preferring the sans .h #defines.

Obviously, on my machine iostream is equivalent to iostream.h.

It's puzzling to me why it was necessary to make iostream when 
iostream.h works just fine.  (That's a retorical question aimed at
the C++ godz).

THis issue touches on portability.  Here's a guide that I found
interesting:

http://www.mozilla.org/hacking/portable-cpp.html
-- 
Mike

Two hundred years ago, we note mischievously, the average American or 
European had a standard of living not very much superior to that of the
average man in India or China. -- dailyreckoning.com



Reply to: