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

Re: c++ hello world help



Kevin Mark <kmark+debian-user@pipeline.com> writes:

> Hi D-u,
> I'm trying to get gcc to compile some basic c++ programs and I'm running
> into some probably some really basic setup mistakes.
> gcc works with C programs.
> but c++ programs cant find the libs.
> =====================================================
>
> ~/cpluscplus\% cat page23.cpp 
> #include <iostream.h>
> int main() { cout << "Hello, World!\n"; return 0; }

This code uses features which have been obsolete since at least
seven years, probably longer (<iostream.h> header, "cout" in global
namespace).

> ~/cpluscplus\% g++ page23.cpp 
> In file included from /usr/include/c++/3.3/backward/iostream.h:31,
> from page23.cpp:1:
>  /usr/include/c++/3.3/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.
>  kevin@165.247.40.180/730/0 :~/cpluscplus\
> (this compiles)

The complier correctly diagnoses that the program uses antiquated
language features.  This is a friendly reminder that if the last seven
or more years haven't been long enough to catch up with the language,
you'd better hurry up, since compilers will not support the early 1990's
C++ forever. ;-)

> ~/cpluscplus\% gcc page23.cpp

This is not supposed to work.  Use "gcc" for C programs and "g++" for
C++ programs.

Martin


-- 
   ,--.    Martin Dickopp, Dresden, Germany                 ,= ,-_-. =.
  / ,- )   http://www.zero-based.org/                      ((_/)o o(\_))
  \ `-'                                                     `-'(. .)`-'
   `-.     Debian, a variant of the GNU operating system.       \_/



Reply to: