Mike McCormack wrote:
I'm curious, what is the reason for the special case handling for MSVC and GCC when we have to do the portable way anyway?
I can see two reasons:
- The portable way adds a (non-standard) symbol.
This could be fixed by adding a _ prefix.
- The static string declaration may not be discarded by some compilers,
so it may needlessly increase the size of our binaries.
Unless MSVC or GCC do not do this optimization (and I'm sure both do) this is no argument.
Actually those 2 non-standard ways put additional burden on the optimizer - if one of those wide string literals is used multiple times the optimizer has to make sure that the compiler doesn't generate a copy for each reference (and I'm not so sure if GCC / MSVC do this, especially since writeable strings (yea, it's const but still) were only recently forbidden by GCC and I guess they are allowed in MSVC).
Felix