Question

I receive an error compiling a C++ program in which of the lines makes a call from "std::system(SomeString)". This program compiled 3 years ago, but when compiling it today, I receive an error that states ‘system’ is not a member of ‘std’. Is there something that I must import to use std::system, has it been abandoned, or has it moved to another header file.

Was it helpful?

Solution

std::system is (and always has been) in <cstdlib>.

It is not defined by the C++ standard whether standard headers include each other, and if so which ones. So it's possible that 3 years ago, on a different compiler or a different version of the same compiler, your code worked by accident, because one of the headers you include just so happened to include <cstdlib>. On the compiler/version you're using now, it doesn't.

OTHER TIPS

Do you have this?:

#include <cstdlib>

Make sure you have #include <cstdlib> in your code.

I have tried. It work both ways in vs2008 -- "std::system()" or "system()". And you want to include either stdlib.h or cstdlib

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top