I've encountered this issue while trying to port my C++ source code from HP-UX to Linux. When I try to compile the C++ source code on Linux, what happens is that it complains that components (from the standard C++ library) don't exist. Placing the line using namespace std; at the top of the source code seems to fix the problem. When I try to recompile the code on HP-UX, the aCC compiler complains that only namespace names are valid here ( it doesn't consider std a valid namespace ). I was wondering if there was a way to get around this issue so that the source code is binary compatible with both HP-UX's long deprecated C++ compiler and LINUX's GCC compiler.
This sucks, but you can do this:
#ifndef __HP_aCC
using namespace std;
#endif
Defines from here, and I have no way to verify.
You could use pre-proccessors to check for the OS and whether or not to include namespace std
; So if your OS is not HP aCC, it doesn't includes std, otherwise it does. Like so:
#ifndef __HP_aCC
using namespace std;
#endif
or if you want to check for linux and win and only use namespace std if its those OS; you can also do it like this:
#if defined(WIN32) || defined(LINUX)
using namespace std;
#endif
Hope that helped!
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