I get these errors after issuing a g++ command on a .cpp file: error: ‘exit’ was not declared in this scope error: ‘printf’ was not declared in this scope
The problem is that when I compiled this program on another linux machine, everything went fine. I tried searching around, but all I found was that I need to include files like 'stdlib.h'.
Could it be I'm missing some library on my OS? If so, what might it be?
Recent versions of GCC have gotten stricter in what responsibilities the programmer needs to fulfill. Include the cstdlib
, cstdio
, etc. header and access these functions from the std
namespace.
Specifically for ‘exit’ was not declared in this scope
all you need is:
#include <stdlib.h>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With