User forums > Using Code::Blocks

auto-include of string library

(1/1)

ChickenCow:

--- Code: ---#include <iostream>
using namespace std;

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

--- End code ---

This results in no compiler errors even though I have not explicitly included the string library.  Is this inherent to GCC or is this something that C::B is doing?  I looked through the compiler options, but I didn't see anything about auto-including libraries.  I did not, however, peruse the compiler/linker switches because I am not terribly familiar with them.

Is there a way I can enforce stricter checking to ensure that the library must be included (mostly for compiler compatability on another IDE)?

Thanks.

tiwag:
no CodeBlocks doesn't anything AUTO***

try this

--- Code: ---#include <iostream>

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

--- End code ---

and this

--- Code: ---#include <iostream>

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

--- End code ---

then you'll find the answer  :P

Navigation

[0] Message Index

Go to full version