#Does it matter where I declare a static const in my file?
20 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
you can put them anywhere you want, they just need to be declared before they are used
It's allocated before the program starts either way?
yeah, all static initialization runs before main()
(not counting static init inside of functions)
Is there a way and / or is it desirable to tag the types of those variables when you first use them?
wdym?
something like
static bool var_used = false;
static T var = (var_used = true, T(...));
perhaps
and what would be the purpose of that?
identifying whether var was initialized or not
this only makes sense for static objects in functions though
I find it somewhat dubious
well, it doesn't make sense if they're in the same scope
void awoo() {
static bool var_used = false;
if (something) {
static T var = (var_used = true, T(...));
...
}
...
}
but yeah, it's pretty dubious
I dunno, just seemed convenient to make it clear what type a variable is, if it was initialized a lot earlier in the file?
syntax highlighters usually give different colors to local variables, function parameters, and globals
This question is being automatically marked as stale.
If your question has been answered, run !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.
!solved