Menu

string on win/unix

2003-01-19
2012-09-26
  • Nobody/Anonymous

    i wrote the following program
    .
    #include <string>
    .
    .
    string myString = "dev";
    . (etc)
    in win/dev/g++ it works fine
    in linux/gcc it does not compile because it does not know about strings.

    can anyone help?

    thank you

     
    • Nobody/Anonymous

      You are using the gcc in linux ?. It is the gcc that has been ported to windows ( mingw ) that Dev uses. Now without the rest of the code to see i will ask you a question, because strings don't live alone, does your windows code have any specific windows OS calls ect, if so you will need to do two things.

      1. remove the specific windows code into a file of it's own.
      This will be true for the linux code as well.

      2. The rest of your code keep with standard C or C++ ( whatever your lnaguage of choice is ) because this ( 99%) will port over.

      And just an extra: Use the newer gcc out, that way your code remains up to date.

      :<mi~

       
    • Nobody/Anonymous

      thank you for your reply
      i am using gcc in linux to test the code before it is turned in at school and compiled on unix/gcc.  we are to use strict ansi and there are no specific os commands or gui...it is a data strucures class.  this particular program is about half a page just to play with unix/c++ before it counts.  the big problem is if i can't get a ansi standard class to work, how am i to get my own classes to work.

       
    • Nobody/Anonymous

      thank you for your reply
      i am using gcc in linux to test the code before it is turned in at school and compiled on unix/gcc.  we are to use strict ansi and there are no specific os commands or gui...it is a data strucures class.  this particular program is about half a page just to play with unix/c++ before it counts.  the big problem is if i can't get a ansi standard class to work, how am i to get my own classes to work.

       
    • Nobody/Anonymous

      thank you for your reply
      i am using gcc in linux to test the code before it is turned in at school and compiled on unix/gcc.  we are to use strict ansi and there are no specific os commands or gui...it is a data strucures class.  this particular program is about half a page just to play with unix/c++ before it counts.  the big problem is if i can't get a ansi standard class to work, how am i to get my own classes to work.

       
    • Nobody/Anonymous

      i found the problem.  i was lacking the line
      using namespace std;

      it is still interesting that win/dev did just fine while
      linux/gcc had to have that line.

       
      • Anonymous

        Anonymous - 2003-01-20

        GCC 2.95 does not support namespaces, GCC 3.2 does. The latest MinGW is 3.2.

        Type gcc -v at the command line to check your version.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.