Re: gcc not seeing.

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

 



On Wed, 6 Nov 2002, Darrel wrote:

>Date: Wed, 6 Nov 2002 23:06:51 -0800
>From: Darrel <Darrel@bak.rr.com>
>To: psyche-list@redhat.com
>Content-Type: text/plain; charset=US-ASCII
>List-Id: Discussion of Red Hat Linux 8.0 (Psyche) <psyche-list.redhat.com>
>Subject: gcc not seeing.
>
>I have no idea what has changed in gcc 3.2 that is so different I can't compile anything.
>
>--------------
>#include <iostream.h>
>
>int main()
>{
>	cout << "Hello World\n";
>	return 0;
>}
>--------------
>[Irv@snail cplusplus]$ gcc helloworld.c -o helloworld
>helloworld.c:1:22: iostream.h: No such file or directory
>helloworld.c: In function `main':
>helloworld.c:5: `cout' undeclared (first use in this function)
>helloworld.c:5: (Each undeclared identifier is reported only once
>helloworld.c:5: for each function it appears in.)
>
> I tried iostream and iostream.h. 'g++ <filename>' seems to work after dumping a bunch of errors but then I can only get a.out filename. whats wrong with gcc blah.c -o blah.binary?

For starters, you're trying to use the C compiler to compile C++.  
Use "g++" for compiling C code, not "gcc".  Also, your code is 
very legacy.  By using the proper compiler to build the code, and 
reading it's warnings, it will tell you what you are doing wrong.

[root@devel root]# g++ -Wall helloworld.c -o helloworld
In file included from 
/usr/include/c++/3.2/backward/iostream.h:31,
                 from helloworld.c:1:
/usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: 
#warning This file includes at least one deprecated or antiquated 
header. Please consider using one of the 32 headers found in 
section 17.4.1.2 of the C++ standard. Examples include 
substituting the <X> header for the <X.h> header for C++ 
includes, or <sstream> instead of the deprecated header 
<strstream.h>. To disable this warning use -Wno-deprecated.

[root@devel root]# ./helloworld
Hello World


As you can see, g++ compiles your code just fine, and it executes 
as well.  Your code is not following C++ standard behaviour 
however hence the warnings.

Hope this helps.

-- 
Mike A. Harris		ftp://people.redhat.com/mharris
OS Systems Engineer
XFree86 maintainer
Red Hat Inc.



-- 
Psyche-list mailing list
Psyche-list@redhat.com
https://listman.redhat.com/mailman/listinfo/psyche-list

[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux