Thread: Compiler Issues (Works on older not newer)

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    63

    Compiler Issues (Works on older not newer)

    Hola Amigos:

    Comin atcha for another semester! They upgraded the compilers on the systems at school and now my redhat 7.1 seems to be out of date! it compiles fine on mine, but when brought over to the school's systems i get this message:

    'string' is used as a type, but is not defined as a type


    for every string declaration in all of my structs...

    is there some special casting i have to do? i'm mental right now so i'll let it sit overnight

    thanks
    SS3X

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    It's because you are using a string from <string> but haven't declared it as a std::string, or put a using std::string or a using namespace std; in the scope of the string declaration.

    IE,

    illegal but older versions of gcc will compile

    Code:
    #include <string>
    
    int main() {
        string a;
        return 0;
    }
    Legal, how it should be done.

    Code:
    #include <string>
    
    int main() {
        std::string a;
        return 0;
    }
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    really? i had gcc 3.2 and it compiled your illegal example fine. but your point is still valid.

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    63
    hey man you rock!

    i never new about that std:: prefix, i just used the old gcc..

    glad you were around to help me along the way

    much appreciated
    SS3X

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    63
    how do i find out the version of gcc i have and my univ has? is there any command out there for that?
    SS3X

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Type "which gcc" in your console window and hit enter.
    Alternately, just type "gcc" by itself, or your can likely use "gcc --help" or "gcc /?".

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to Ensure my program works across platforms??
    By hanhao in forum C++ Programming
    Replies: 8
    Last Post: 07-09-2005, 03:43 AM
  2. compiler differences
    By white in forum C Programming
    Replies: 1
    Last Post: 02-18-2005, 02:58 PM
  3. OpenScript2.0 Compiler
    By jverkoey in forum C++ Programming
    Replies: 3
    Last Post: 10-30-2003, 01:52 PM
  4. Borland command line compiler issues.
    By NinePin in forum C Programming
    Replies: 5
    Last Post: 09-05-2002, 05:44 PM
  5. Replies: 6
    Last Post: 01-07-2002, 02:46 AM