Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Kayle on August 16, 2009, 12:14:04 am

Title: Possible to use string without string library
Post by: Kayle on August 16, 2009, 12:14:04 am
Hello,

I've discover code::blocks today and I'm very surprising by this very good IDE.

Unfortunately, I've a problem with the iostream and string libraries. During a test, I've seen that I've the possibility to use a string without make an include of <string>. In others terms, the code below works instead invoke an error:

Code
#include <iostream>

int main(){
   std::string s1 = "C::B is the best.";
   std::cout << s1 << std::endl;
   return 0;
}

How is it possible and how can I avoid this? Because on VS2008 I've and error if I try to do that...

Sorry for my english, I'm french.

Thanks
Title: Re: Possible to use string without string library
Post by: Jenna on August 16, 2009, 12:47:02 am
Not related to C::B and therefore vioalting our forum rules.
Such a thread normally gets locked, so be warned.

Be aware C::b is "just" an IDE not a compiler.

Nevertheless:

iostream includes ostream,
ostream includes ios,
ios includes iosfwd,
iosfwd includes bits/stringfwd.h,
bits/stringfwd.h defines string in namespace std

that's the way gcc (at least 4.4) does it, Microsoft, Borland etc. compilers might do it in a different way.