Fwd: help for g++, please

Claudio Bley bley@CS.uni-magdeburg.de
Thu Nov 25 17:37:00 GMT 2004


On Thu, Nov 25, 2004 at 05:42:16PM +0100, Anton Greil wrote:
> 
> 
> ----------  Weitergeleitete Nachricht  ----------
> 
> Subject: help for g++, please
> Date: Donnerstag, 25. November 2004 17:22
> From: Anton Greil <greil@muc.de>
> To: gcc-help@gcc.gnu.org
> 
> Could you give me please some advices how to update my *C and *h files
> of my C++ programs?
> 
> I coded and run these programs on base of the GNU g++ compiler
> of SuSE Linux 8.0 which I installed just 3 years ago.
> Now I installed SuSE Linux 9.1 where the command "g++ -v" gives:
>   ".... gcc version 3.3.3 (SuSE Linux)".
> 
> Invoking the new g++ on my old programs (which worked well under the old
> g++ version) creates many and many error messages in connection
> with header files.
> 
> Is there an information which concerns the changings in header files
> (and perhaps some other new conventions) since 2001 which I should
> apply that I can run my programs again?
> 
> What about the actual C++ ISO standard and its realization by g++ ?
> What about please further developments in C++ ? Is there a web-site for
> this question?
> Where can I download please a corresponding C++ manual ?
> 
> Please excuse my questions from a today tired web-searching person
> who would like in the moment to write a letter to a human person!
> 
> Thank you very much for your patience!
> 
> Anton Greil
> 
> -------------------------------------------------------

Hi,

these type of questions seem to turn up over and over again. Well, here
is an extract of a FAQ I plan to write/put online sometimes which might
answer a few of your questions. (any suggestions, changes, corrections
to this article more than welcome, of course) 

<question>
Why can't gcc/g++ compile this quite simple C++ program?
</question>
<answer>
Most likely, your program is not compliant with the new C++ standard
(ANSI/ISO ...), i.e. it is not correct C++.

Here are a few things to check:

1) Make sure that your main function's return type is `int'. 
   (void is not valid!)

2) Include all the necessary standard headers you're using. 

   Note, that the standard headers don't have an extension--e.g.
   use `iostream' instead of `iostream.h'.

3) Utilize the `std' namespace. 

   The STL (Standard Template Library) has its own namespace called
   `std'. In order to use an element of the STL you could 

   a) explicitely specify the namespace:  <code lang="c++">std::cout
   << "foo";</code>
   b) introduce selected members into the current namespace: 
      <code lang="c++">use std::cout; cout << "foo";</code>
   c) include the whole std namespace: 
      <code lang="c++">using namespace std; cout << "foo";</code>
   
Here is a complete, standard compliant (as of $today) "hello world"
C++ program:

<code lang="c++">
#include <iostream>

int main()
{
  using std::endl;
  
  std::cout << "hello, world!" << endl;
}
</code>  
</answer>



But, as you didn't go into any detail and haven't provided any code, warning / error 
messages from GCC you're on your own. If you have a problem you can't solve yourself
try to be more specific and elaborate a little on your problem. If possible/feasable
provide small complete example code which exhibits the problem.

> What about the actual C++ ISO standard and its realization by g++ ?
> What about please further developments in C++ ? Is there a web-site for
> this question?
> Where can I download please a corresponding C++ manual ?

The GCC team works very hard to totally adhere to the C++ ANSI/ISO standard. The
corresponding manual would be the most recent amendment of ISO 14882. For further
developments of C++ you could probably have a look at http://www.open-std.org.

HTH
-- 
Claudio



More information about the Gcc-help mailing list