J
JKop
Let's say you have a global const variable for the name of your application.
Which do you think is preferrable?:
A) char const g_application_name[] = "ChocolateCheese";
B) const char* const g_application_name = "ChocolateCheese";
A -> The only drawback I'm thinking of is that maybe the string will be in
memory twice, and that it would be copied into my "application_name" array
from somewhere else in memory.
B -> There's no worries about it being in memory twice, but still an extra
pointer may be allocated.
Whenever I make a global string like this, I always find myself pondering
for ~20 seconds over which I should go for, so I may aswell burry it once
and for all!
Also... can anyone summarize the rules for global const variables please? I
know there's some bullshit along the lines that they can't be accessed from
within another translation unit unless "extern" is applied to the
*definition*. How exactly does that work?
-JKop
Which do you think is preferrable?:
A) char const g_application_name[] = "ChocolateCheese";
B) const char* const g_application_name = "ChocolateCheese";
A -> The only drawback I'm thinking of is that maybe the string will be in
memory twice, and that it would be copied into my "application_name" array
from somewhere else in memory.
B -> There's no worries about it being in memory twice, but still an extra
pointer may be allocated.
Whenever I make a global string like this, I always find myself pondering
for ~20 seconds over which I should go for, so I may aswell burry it once
and for all!
Also... can anyone summarize the rules for global const variables please? I
know there's some bullshit along the lines that they can't be accessed from
within another translation unit unless "extern" is applied to the
*definition*. How exactly does that work?
-JKop