1.
Using class-keyword is just a (elegant,propper,legal) workaround
solution in the end.
Because a global constant definition should work simple by its definition itself, like all other shared data. But it works and may satisfiy.
2.
it is simply not possible with "basics"(just definition and declarations) to keep (also onno mentioned)
the following condition list.
- typesafe data
- no multiple definition or memory usage
- global scope
- possible inlining
the closest i reached with basics to hold the conditions
was (i know i repeat this).
Code: Select all
//the definition may me done in a modul you like
----------------------------------------------------------
#ifdef USE_DEFINITION
extern const type c_name = value;
#endif
//all other moduls will use this
----------------------------------------
#ifndef USE_DECLARATION
#define USE_DECLARATION
extern const type c_name;
#endif
RESULT:
- typesafe data -> OK
- no multiple definition or memory usage ->OK
- global scope -> OK
- possible inlining ->(OK) BUT NOT GUARANTEED
At the end anybody has to decide between
- or for a (natural c++ class,any other) workaround,
- or using static const each modul
- or something like this.
- or some other solution
So, and now one more of my final questions (:-)).
Should it not easily be like this: 1x gl const def and X x gl const decl. ?