Re: GCC Compile Failure

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

 



> Hi, again, John,
>
> You need to parenthesize printf's argument, too, so your printf should
> look more like this:
>
> printf ("Hello, world.\n");
>
> After I solved that problem, I compiled your program and ran it on my
> Sunblade 100 workstation that runs gcc-4.1.1.  The C++ compiler, g++,
> warned me that iostream had been deprecated.  That's why I don't know
> what header file you need to include instead of iostream.h.  The warning
> said that I could suppress it with a compiler directive, but I think
> it's better to include the header file meant to replace iostream.h  By
> the way, I'm not a C++ programmer.


1) That header would be <iostream>.
(When in doubt, drop the .h from old C++-header includes.)

2) The 'cout' ostream resides in the std:: namespace:
I suggest:

	using std::cout;
or
	using namespace std;

somewhere before main, otherwise, every reeference to cout will need to be
prefixed as "std::cout".

3) In Standard C++, main() must return an int, e.g.:

	int
	main(int argc, char* argv[]) { ... }

I wouldn't rely on the old C-like behavior of implicit return type (int).

> > Hello GCC Helpers,
> >
> > This is a program I wrote:
> >
> > #include <glibc>
> > #include <stdio.h>
> > void cout();
> > main()
> > {printf "Hello World. /n";
> > 	cout << "Hello/n";
> > return 0;
> > }

Fang


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux