Reputation: 8678
I got a fatal error that the file or directory <stdlib>
is not found on ubuntu 11.xx
when I typed #include <stdlib>
.
Is <stdlib>
deprecated/removed, or is there something wrong with my GCC installation?
Upvotes: 6
Views: 15138
Reputation: 385098
Presumably you are attempting to include the C standard library header stdlib.h
.
Thing is, in C++, the old C headers x.h
are deprecated; you should not use them. Fortunately, C++ allows you to use C++ versions of them:
#include <cstdlib>
It's pretty much the same thing, but wrapped into the std::
namespace ... and not deprecated.
Anyway, you got your error because there's certainly no standard header named just stdlib
.
Upvotes: 0
Reputation: 9179
In C++ code, include 'cstdlib' instead.
#include <cstdlib>
If you are using C, include 'stdlib.h'
#include <stdlib.h>
In c++ code, always prefer the cXXX include instead of XXX.h
Upvotes: 18