Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
static variables in cbplugin.h
oBFusCATed:
Morten: do you know the reason why this is not an enum, but a number of static variables?
thomas:
ISO 14882 3.5.3 states that names having namespace scope automatically have internal linkage if they are either const or static and not at the same time explicitly extern. Which means that the linkage is irrespective of the presence of static because of const. The rationale for that is given in Appendix C. The standard makes explicit mention of inclusion of headers in many compilation units.
As to why these values are not an enum, the likely reason is simply that the person who wrote that code (Yiannis) wrote it that way. There is no real advantage or disadvantage to either optimization-wise.
MortenMacFly:
--- Quote from: oBFusCATed on December 29, 2011, 01:35:41 pm ---Morten: do you know the reason why this is not an enum, but a number of static variables?
--- End quote ---
Usually this is because if you compare the values against another one which is an INT, too you don't need to take care to cast the values to avoid compiler warnings. At least that's when I personally prefer static const instead of an enum.
ollydbg:
--- Quote from: MortenMacFly on December 29, 2011, 04:43:50 pm ---Usually this is because if you compare the values against another one which is an INT, too you don't need to take care to cast the values to avoid compiler warnings.
--- End quote ---
I guess that if it was defined as a enum, then the user/client will define same enum type variables too, some kind of type consistent. :)
"Int type" basically does not have much specific information like enum type.
MortenMacFly:
--- Quote from: ollydbg on December 30, 2011, 01:07:56 am ---I guess that if it was defined as a enum, then the user/client will define same enum type variables too, some kind of type consistent. :)
--- End quote ---
I thought more in a direction to compare it against a value of a control or alike. There, you have no choice other than INT or SIZE_T or alike.
Navigation
[0] Message Index
[*] Previous page
Go to full version