Enums v. Defines

Linkman226

#anarchy
Joined
Sep 14, 2007
Messages
2,493
What exactly is the reason that Rhye chose to use #define instead of enum? The latter is a lot easier when adding stuff to the game.
 
In theory, defines are faster. That's because defines are actually part of the C++ preprocessor, which means that all occurences of a defined namespace are replaced in the source code before it is even compiled, i.e. they use absolutely no disk space.

Enums on the other hand are only a certain type of constants, which are still stored somewhere and have to be accessed, which can take up some time.

I don't think that it makes a practical difference in this case, though.
 
That's very interesting. Thank you. Although considering how much MORE time it take to add new stuff to defines, I think I'm gonna go with enums like edead.
 
Yeah, sure. That makes especially sense for wonders which are difficult to change when a new building is added.
 
Oh I just realized that enums would require explicit type casting (I think)

This does not look pretty

Back to #define's :lol:
 
Wouldn't it be possible to use the actually existing enums TechTypes and BuildingTypes? That would make things easier after all ...
 
Back
Top Bottom