On May 26, 1:04 pm, Charles Bailey <usenetspa...@hashpling.orgwrote:
On 2008-05-26, James Kanze <james.ka...@gmail.comwrote:
Visible how? If all you're interested in is that it shows up in
the output of strings, then just including a file with:
static char const copyright[] = "..." ;
should do the trick. You're compiler may even have an option
which will force an include at the start of compilation.
Although some compilers with some optimization settings will
drop the variable from the object file if it's not 'used'
elsewhere in the translation unit. (Being static it can't be
used from any other TU.)
The obvious answer to that is: don't use those compilers, or
don't use them with those settings:-).
In fact, of course, it's a bit more awkward, because if the
variable is a POD with static initialization (as it is here),
then such a modification is quite valid; there's no way the
program can tell. If it becomes an issue, some sort of
work-around using dynamic initialization could be used (but
beware---this will impact on start-up times). Another
alternative would be to make the variable non-static, and hack
the name of the file into the name of the variable, to avoid
duplicate definitions. (Either solution can easily be generated
automatically.)
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34