I’m working on a cross platform project that uses STL. The other compiler includes STL support by default, but in VS2005 I need to add the following before the class definitions that use STL items:
#include <cstdlib> using namespace std;
Is there a VS2005 option that would set this automatically? It’s just a bit tedious to work around. I’m just trying to avoid lots of #ifdefs in the source –
EDIT: The other compiler is the IAR workbench for the ARM 926x family. Perhaps I should get them to explicitly do the includes?
Also – is ‘std::map<>’ preferred over ‘using namespace std; map<>’ ?
The IAR compiler does not support the
stdnamespace (I’m not sure why, because it does support namespaces in general if I remember right).If you look in the runtime headers for IAR you’ll see that they do some macro gymnastics to work around that (the runtime is licensed from Dinkumware, who provide runtimes for quite a few compilers).
You may need to do something similar if you want your stuff to work in multiple environments. A possible cleaner alternative is to just include the ‘
using namespace std;‘ directive. I might be wrong, but I think the IAR compiler essentially ignored it (it didn’t mind that you were using a namespace it didn’t know about). A lot of people will think that’s ugly, but sometimes you gotta do what the compiler you have wants you to do.