Global using namespace pollution

Global using namespace pollution

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
zenzike
Posts: 77
Joined: 12 Apr 2008, 13:19

Global using namespace pollution

Post by zenzike »

I've noticed a few places where

Code: Select all

using namespace std;
is used in header files. Is it me being picky, or should we not avoid doing this? I was pretty flumoxed earlier when I didn't have to write

Code: Select all

std::string
to define a string, and pretty horrified to see people using namespaces that fed through globally.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Global using namespace pollution

Post by Tobi »

We should avoid doing that. Personally I don't really mind if you use

Code: Select all

using namespace std;
in a .cpp file, but it's really bad indeed in a header file.

Feel free to submit a patch to correct it. :P
zenzike
Posts: 77
Joined: 12 Apr 2008, 13:19

Re: Global using namespace pollution

Post by zenzike »

Feel free to submit a patch to correct it. :P
Where should I submit? I don't have svn access...
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Global using namespace pollution

Post by KDR_11k »

Create a .patch file and post it somewhere, preferrably in Mantis.
zenzike
Posts: 77
Joined: 12 Apr 2008, 13:19

Re: Global using namespace pollution

Post by zenzike »

Patch submitted.

Quite a few header files across the board had included using namespace std. I've removed all occurrences and modified the headers so that they use std:: statements as appropriate. I've also modified cpp files so that they have using namespace if they require it.

I've made no attempt to rectify the situation in the Global/AI/ folder; there are many uses of using namespace std in header files there, but since they're library files, I don't think it's such a problem.
Post Reply

Return to “Engine”