Hi! I've just installed Code::Blocks, and I imported my current Dev-C++ project into it and tried to compile it, but received a few errors. Specifically, the functions time(), numeric_limits<streamsize>::max(), and rand() were unrecognized. After commenting out or altering those three lines (each function was only used once in the program), everything works perfectly. What do I need to do to make Code::Blocks recognize them? My understanding is that both IDEs are using gcc to compile, so I don't see why there's any difference. Thanks!
...Wow. I can't believe I made such a rookie mistake. That leads right into a new question: Why would it work without those in Dev-C++? :-/ I seriously thought I had everything #included because it had been compiling flawlessly.
Dev-C++ comes with an old version of gcc. Apparently, some of its headers were unnecessarily including some other headers, which has been fixed in newer versions.
As long as you have no guarantee that another header is including a header you need, you should explicitly include it yourself.
What other headers a particular header includes is not defined in the standard; it's up to the implementation. For example, most implementations of <sstream> include <string> internally, but they're not required to do it, so you could in principle find an implementation where this program doesn't compile:
1 2 3 4 5 6
#include <sstream>
//#include <string>
std::string s;
int main(){}