www.digitalmars.com         C & C++   DMDScript  

c++ - Accelerated C++

reply "jim p" <x y.com> writes:
I'm finally getting around to teaching myself C++ using DM.
The book I'm using is Accelerated C++.
I only started today, but the already the simple examples (said to be ANSI)
are not compiling.

For example:

    // a small C++ program
    #include <iostream>

    int main()
    {
         std::cout << "Hello, world!" << std::endl;
         return 0;
    }

This fails because it requires the #include to include the .h extension.
Changing this and recompiling gives the following messages:

tip.cpp:
        std::cout << "Hello, world!" << std::endl;
                ^
tip.cpp(6) : Error: 'cout' is not a member of namespace 'std'
        std::cout << "Hello, world!" << std::endl;
                                                 ^
tip.cpp(6) : Warning 6: value of expression is not used
tip.cpp(10) : Error: need at least one external def
--- errorlevel 1


OK, I know it works when std:: is removed, but why ??

Jim
Jul 02 2003
next sibling parent reply "Andrew Edwards" <edwardsac spamfreeusa.com> writes:
"jim p" <x y.com> wrote...
 OK, I know it works when std:: is removed, but why ??
I think it's the same reason you cannot use the following: using namespace std; It is not yet implemented; DM it is not yet fully ANSI compliant. Regards, Andrew
Jul 02 2003
parent reply "jim p" <x y.com> writes:
So the -A switch for strict ANSI is of little use ?




"Andrew Edwards" <edwardsac spamfreeusa.com> wrote in message
news:bdu928$2ai6$1 digitaldaemon.com...
 "jim p" <x y.com> wrote...
 OK, I know it works when std:: is removed, but why ??
I think it's the same reason you cannot use the following: using namespace std; It is not yet implemented; DM it is not yet fully ANSI compliant. Regards, Andrew
Jul 02 2003
parent "Andrew Edwards" <edwardsac spamfreeusa.com> writes:
"jim p" <x y.com> wrote ...
 So the -A switch for strict ANSI is of little use ?
I wouldn't say that. Considering that the follwing code works just fine, I would say it's just not fully implemented as yet. // a small C++ program #include <iostream.h> // not the added extension .h using namespace std; // as stated by the ANSI standard int main() { cout << "Hello, world!" << endl; return 0; }
Jul 02 2003
prev sibling next sibling parent reply "Wichetael" <wichetael gmx.net> writes:
This is because the way the SGI iostream library is set up, it is not fully
implemented yet and is still experimental. There are indeed two versions of
the iostreams library, one which is iostream.h, which simply defines
everything in the global namespace and iostream, which defines everything in
the std namespace. The SGI iostreams implementation does not yet include the
iostream header, which is why you get an error for your program. What you'd
want to do is use STLport instead, you can get it off the DM CD or download
the latest version from the DM site. Follow the installation instructions
and make sure you place the stlport path before the SGI stl path in the
SC.INI file. Try your initial program again and you should find that it
compiles and works beautifully.

Regards,
Remko van der Vossen


"jim p" <x y.com> wrote in message news:bdu7ib$294j$1 digitaldaemon.com...
 I'm finally getting around to teaching myself C++ using DM.
 The book I'm using is Accelerated C++.
 I only started today, but the already the simple examples (said to be
ANSI)
 are not compiling.

 For example:

     // a small C++ program
     #include <iostream>

     int main()
     {
          std::cout << "Hello, world!" << std::endl;
          return 0;
     }

 This fails because it requires the #include to include the .h extension.
 Changing this and recompiling gives the following messages:

 tip.cpp:
         std::cout << "Hello, world!" << std::endl;
                 ^
 tip.cpp(6) : Error: 'cout' is not a member of namespace 'std'
         std::cout << "Hello, world!" << std::endl;
                                                  ^
 tip.cpp(6) : Warning 6: value of expression is not used
 tip.cpp(10) : Error: need at least one external def
 --- errorlevel 1


 OK, I know it works when std:: is removed, but why ??

 Jim
Jul 02 2003
parent reply "jim p" <x y.com> writes:
I've updated my CD releases until the latest one.
I've downloaded and installed the STLport files.
When I try to make the library I get the following

 make -fdm.mak clean all
Error on line 63: bad syntax for implicit rule, should be .frm.to: Any ideas why this is happening ?? James "Wichetael" <wichetael gmx.net> wrote in message news:bdug0k$2h2u$1 digitaldaemon.com...
 This is because the way the SGI iostream library is set up, it is not
fully
 implemented yet and is still experimental. There are indeed two versions
of
 the iostreams library, one which is iostream.h, which simply defines
 everything in the global namespace and iostream, which defines everything
in
 the std namespace. The SGI iostreams implementation does not yet include
the
 iostream header, which is why you get an error for your program. What
you'd
 want to do is use STLport instead, you can get it off the DM CD or
download
 the latest version from the DM site. Follow the installation instructions
 and make sure you place the stlport path before the SGI stl path in the
 SC.INI file. Try your initial program again and you should find that it
 compiles and works beautifully.

 Regards,
 Remko van der Vossen


 "jim p" <x y.com> wrote in message news:bdu7ib$294j$1 digitaldaemon.com...
 I'm finally getting around to teaching myself C++ using DM.
 The book I'm using is Accelerated C++.
 I only started today, but the already the simple examples (said to be
ANSI)
 are not compiling.

 For example:

     // a small C++ program
     #include <iostream>

     int main()
     {
          std::cout << "Hello, world!" << std::endl;
          return 0;
     }

 This fails because it requires the #include to include the .h extension.
 Changing this and recompiling gives the following messages:

 tip.cpp:
         std::cout << "Hello, world!" << std::endl;
                 ^
 tip.cpp(6) : Error: 'cout' is not a member of namespace 'std'
         std::cout << "Hello, world!" << std::endl;
                                                  ^
 tip.cpp(6) : Warning 6: value of expression is not used
 tip.cpp(10) : Error: need at least one external def
 --- errorlevel 1


 OK, I know it works when std:: is removed, but why ??

 Jim
Jul 02 2003
parent reply "Walter" <walter digitalmars.com> writes:
"jim p" <x y.com> wrote in message news:bdv45r$5kk$1 digitaldaemon.com...
 I've updated my CD releases until the latest one.
 I've downloaded and installed the STLport files.
 When I try to make the library I get the following

 make -fdm.mak clean all
Error on line 63: bad syntax for implicit rule, should be .frm.to: Any ideas why this is happening ??
To build the STLport libraries and dll's: cd \dm\stlport\src smake -f dm.mak which will build them into \dm\stlport\lib. To install them: xcopy \dm\stlport\lib\*.lib \dm\lib xcopy \dm\stlport\lib\*.dll \dm\bin Please check out \dm\stlport\readme.txt for more details.
Jul 02 2003
parent "jim p" <x y.com> writes:
Cheers Walter.
I found the readme.txt at the same time I got your reply.



"Walter" <walter digitalmars.com> wrote in message
news:bdv7pa$9es$2 digitaldaemon.com...
 "jim p" <x y.com> wrote in message news:bdv45r$5kk$1 digitaldaemon.com...
 I've updated my CD releases until the latest one.
 I've downloaded and installed the STLport files.
 When I try to make the library I get the following

 make -fdm.mak clean all
Error on line 63: bad syntax for implicit rule, should be .frm.to: Any ideas why this is happening ??
To build the STLport libraries and dll's: cd \dm\stlport\src smake -f dm.mak which will build them into \dm\stlport\lib. To install them: xcopy \dm\stlport\lib\*.lib \dm\lib xcopy \dm\stlport\lib\*.dll \dm\bin Please check out \dm\stlport\readme.txt for more details.
Jul 02 2003
prev sibling parent "Walter" <walter digitalmars.com> writes:
"jim p" <x y.com> wrote in message news:bdu7ib$294j$1 digitaldaemon.com...
 This fails because it requires the #include to include the .h extension.
<iostream> is in \dm\stlport\stlport. Try using the -I\dm\stlport\stlport switch.
Jul 02 2003