(VC++) How to prevent linker throwing away globals it fails to see being used?

Started by
9 comments, last by tanzanite7 10 years, 2 months ago

There is one workaround, however. Tell the compiler you use this symbol /.../

Yeah, that is what i do. Hoped there to be something to avoid per specialization macros - but there are none. Digged up the relevant part in the specs - for the benefit to whoever comes by in future, here goes:

"1. /.../ The implicit instantiation of a class template specialization causes the implicit instantiation of the declarations, but not of the definitions or default arguments, of the class member functions, member classes, static data members and member templates; /.../"

"4 A class template specialization is implicitly instantiated if the class type is used in a context that requires a completely-defined object type /.../"

"7 The implicit instantiation of a class template does not cause any static data members of that class to be implicitly instantiated."

And that is that.

So, here ends the research. A bit torn whether it is of any use to me given the problems with templates (no problems anywhere else) - will see.

At least now i know where the problems lie.

What's the meta-problem behind the problem? There may be a more standard way to achieve your goals without tricking the tools and skirting around the fringes of the spec.

See note 2 in OP.

edit: made the spec excerpts more concise/relevant.

This topic is closed to new replies.

Advertisement