I'm trying to write code that can be compiled with any modern version of g++ and am having difficulties. I wrote the code using Visual Studios and it worked fine but I tried compiling it on another computer and it had problems.
One problem was it didn't recognize the macro EXIT_SUCCESS
. I see here it's defined in cstdlib
but how come in VS I didn't need to import that library?
Also in a .h file I had const private int PI = 3.1416
and on the other computer it didn't like that.
So how do you know what's going to be portable? I thought C (and therefore inherently C++) was invented to be compiled anywhere. I asked this question but think it go misinterpreted, are there certain settings that must be done to the IDE to ensure portability?
EDIT: I might understand it better knowing why did the code compile in Visual Studio without include <cstdlib>
and how do you turn off such feature?