Mailinglist Archive: opensuse (3637 mails)

< Previous Next >
Re: [SLE] gcc won't compile hello world
  • From: "Alan Lenton" <alan@xxxxxxxxxxx>
  • Date: Tue, 29 May 2001 06:56:41 +0100
  • Message-id: <004101c0e804$360feb20$070210ac@xxxxxxxxxxxxxxxxxxx>
Well there would seem to be three possible problems...

1. Based on the earlier error messages those of us who get it to compile OK
may all be using a different library set. For instance in my case

fogg $ gcc -v
Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.2/specs
gcc version 2.95.2 19991024 (release)
fogg $

Your library I notice was an i686 version - it may be a conflict between
the sizes of basic data types, which is screwing up the template
instantiation.

2. There may be some sort of non-printing character in your source that's
messing things up - try displaying it with cat -e

3. The version you are using is more C++ Standards compliant.

There is (supposed to be) a difference between <iostream> and <iostream.h>.
Includes with the .h put the names of their functions into the global
namespace, which means you can access them from anywhere in the file.

Without the .h the function names go into the std namespace. To access them
you need to do one of two things - either include the line

using namespace std;

after the #include <iostream>, or qualify the 'cout' with the namespace
identifier - ie the line becomes

std::cout << "Hello, World!";

The using directive is really frowned upon, but used a lot in C++ books,
unfortunately. This list isn't appropriate to explain why, but if anyone
wants the details they can email me directly :)

alan lenton

----- Original Message -----
From: "EagleIce" <eagleice@xxxxxxxxx>
To: "SuSE e-List" <suse-linux-e@xxxxxxxx>
Sent: Tuesday, May 29, 2001 1:12 AM
Subject: Re: [SLE] gcc won't compile hello world


| On Tuesday 29 May 2001 01:51, Jim Sabatke wrote:
| > Hmmm, it doesn't work for me, (btw, I was using g++):
| [snip]
| > I wonder what is different?
| >
| Now I've made some tests and these compile fine:
| ---
| #include <iostream.h>
| main()
| {
| cout <<"Hello C++!";
| }
| ---
| #include <iostream.h>
| void main(void)
| {
| cout << "Hello, World!";
| }
| ---
| But this one:
| ---
| #include <iostream>
|
| int main() {
|
| cout << "Hello world\n";
|
| }
| ---
| gives me this:
| parse error before character 0240
|
| Cheers,
|
| ei
|
|
| --
| @~~~ EagleIce ~~~~ eagleice@xxxxxxxxx ~~~@
| @~~~~ Running SuSE Linux 7.1 at home ~~~~@
| @~~~~ Caldera OL eDesktop 2.4 at work ~~~@
|
|
|
|
|
|
|
| --
| To unsubscribe send e-mail to suse-linux-e-unsubscribe@xxxxxxxx
| For additional commands send e-mail to suse-linux-e-help@xxxxxxxx
| Also check the FAQ at http://www.suse.com/support/faq and the
| archives at http://lists.suse.com
|
|


< Previous Next >