From: Dean M. B. <mik...@gm...> - 2007-06-11 13:12:08
|
Hi Everyone, I've only recently been developing with MSVC, and while I've been trying to implement the transformations to the message class I hit a nasty snag. Let me identify what the problem is. First, in boost/network/message/transformers/to_upper.hpp I have the following: struct to_upper_placeholder { template <class Selector> struct type : public impl::to_upper_transformer<Selector> { }; } ; extern to_upper_placeholder to_upper_; I also have in boost/network/message/transformers/selectors.hpp: namespace selectors { struct source_selector { }; struct destination_selector { }; }; // namespace selectors extern selectors::source_selector source_; extern selectors::destination_selector destination_; What I'm concerned about, is that the MSVC linker keeps asking for where to look for these externs when I have the following function template in boost/network/transformers.hpp : template <class Algorithm, class Selector> inline impl::transform_impl<Algorithm, Selector> transform(Algorithm, Selector) { return impl::transform_impl<Algorithm, Selector>(); }; This is used in the unit test (which fails to compile in MSVC 8) libs/network/test/message_transform_test.cpp : using namespace boost::network; message msg; msg << source("me"); BOOST_CHECK_EQUAL ( source(msg), "me" ); msg << transform(to_upper_, source_); BOOST_CHECK_EQUAL ( source(msg), "ME" ); Clearly, the 'transform' template method only requires the type information of to_upper_ (an extern to_upper_placeholder) and source_ (an extern selectors::source_selector) but MSVC seems to require that they be linkable from somewhere. Any thoughts on the matter? I haven't tried this in GCC yet, but I'm confident that GCC would know that I don't really need to link to these instances -- that I just need the type to be deduced in the 'transform' template and not care about the actual instances. Help and insight would be most appreciated. Thanks and hope to hear from any one of you soon! (Please update to Revision 17 to get the latest unit tests and implementations from trunk/) -- Dean Michael C. Berris http://cplusplus-soup.blogspot.com/ mikhailberis AT gmail DOT com +63 928 7291459 |