using namespace std -- Does that make the exe huge?

Started by
7 comments, last by Bincho 19 years, 5 months ago
(obviously talking about C++) Should I just say using std::whatever instead of using namespace std;? I made a really small text-based game, and it was like 500k...I figured it'd be under 50, so is it because I said using namespace std? Also, I can just throw those using std::whatever declarations in a header, right?
"Somebody should make a game about pirating video games. That would be interesting."~Chandler
Advertisement
it shouldn't matter, they're going to be linked the same way anyway(and, yes, it's ok use the std:: in headers)
It won't change the file size?
"Somebody should make a game about pirating video games. That would be interesting."~Chandler
using namespace std; is a compile-time resolution tool. It has no impact on linking or binary file size. Your large file size is most likely due to the size of the statically-linked iostream library.
when you compile in Release mode the exe gets much smaller.
FTA, my 2D futuristic action MMORPG
Slightly off-topic, but here's A neat trick that I haven't tried in the .NET compilers to produce really small programs.

-~-The Cow of Darkness-~-
Quote:Original post by Bombario
Should I just say using std::whatever instead of using namespace std;?

In headers, you should preferably fully qualify all the names (std::vector, std::string, et cetera), and not use any using directives. The less you dump into the global namespace, the better. (using bla::whatever over using namespace bla is of course less bad, but as others have pointed out, the reasons have nothing to do with the size of the finished executable.)
You could always just stick your code in it's own namespace, and then you can pollute it all you want.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
Quote:Original post by cowsarenotevil
Slightly off-topic, but here's A neat trick that I haven't tried in the .NET compilers to produce really small programs.



I tried that and my file got bigger. That was with a tic-tac-toe game, though. Using VC++ 2k3

This topic is closed to new replies.

Advertisement