#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    68
    Rep Power
    13

    compiling a simple script in linux


    I just installed RedHat 8.0 on my computer, and when I try to compile a simple c++ program, I get a strange warning about the header include. See:
    http://users.pandora.be/fourtyseven/cplus.jpg

    If I remove the '.h' part in the include, I don't get this warning anymore, but then of course it says that 'cout' is undeclared.

    Could anyone help? Thanks.
    Last edited by poring; December 29th, 2002 at 01:39 PM.
  2. #2
  3. Big Endian
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2001
    Location
    Fly-over country
    Posts
    1,172
    Rep Power
    30
    I could not replicate your problem on my SuSE box. On my box, the program includes the /usr/include/g++/iostream.h file. Your error message says that its including the /usr/include/c++/backward/iostream.h file. The word backward in the path indicates to me that this may be an older file that is included for backward compatability. My guess is that you're using the "wrong" iostream.h file and need to adjust some settings on your machine so your compiles look at a different include directory.

    Also, if you want to leave the .h off your include files, you might want to look at the following post:

    using std namespace; what does it mean?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Flint, MI
    Posts
    328
    Rep Power
    12
    First, compiling from within emacs can be problematic. I generally prefer to work from a command line.

    Second, try the following code to accomplish the same goals:

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main() {
      cout << "Hello" << endl;
      return 0;
    }
    The STL libraries do not use the .h extension, although typically there is a link to the file with a .h extension roaming around on the hard drive. Everything in the STL libraries is within the std namespace, so having that in place will help.
    Clay Dowling
    Lazarus Notes
    Articles and commentary on web development
    http://www.lazarusid.com/notes/

IMN logo majestic logo threadwatch logo seochat tools logo