Advertisement

using namespace std - g++ command switch

Started by February 20, 2005 09:51 AM
1 comment, last by Genjix 19 years, 9 months ago
is there any way to tell g++ to compile all files, using a certain namespace? so that i dont have to type

	using namespace std;
in all my source files?
You shouldn't want to since it will cause portability problems with any compiler lacking such a feature, it's also a great way to confuse readers of your code.
However it can be done by placing the using directive in a header and letting the preprocessor include it automatically in all source files.
// namespace.husing namespace std;
cc -include namespace.h ...
Advertisement
aha, nice solution. Thanks.

This topic is closed to new replies.

Advertisement