Sign in to follow this  
kappa

Does anyone know why this does not work?

Recommended Posts

template<class T>
std::string cast_num( T nmbr )
{
	std::ostringstream s;
	if( s << nmbr )
		return s.str();
	return "\0";
}
I want to convert any number to a string, I found this and it looked like it would work. But when I run it I get the following error: hl error LNK2019: unresolved external symbol _use_Q_snprintf_instead_of_sprintf referenced in function "protected: virtual class std::ostreambuf_iterator<char,struct std::char_traits<char> > __thiscall std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > >::do_put(class std::ostreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,char,long)const " (?do_put@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$ostreambuf_iterator@DU?$char_traits@D@std@@@2@V32@AAVios_base@2@DJ@Z) Anyone know anyother way I can do this? and why this does not work?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by kappa
*** Source Snippet Removed ***

I want to convert any number to a string, I found this and it looked like it would work. But when I run it I get the following error:

hl error LNK2019: unresolved external symbol _use_Q_snprintf_instead_of_sprintf referenced in function "protected: virtual class std::ostreambuf_iterator > __thiscall std::num_put >::do_put(class std::ostreambuf_iterator >,class std::ios_base &,char,long)const " (?do_put@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$ostreambuf_iterator@DU?$char_traits@D@std@@@2@V32@AAVios_base@2@DJ@Z)

Anyone know anyother way I can do this? and why this does not work?


Another way: You shouldn't bother. This is legit code.
Doesn't work: Becuz your C++ standard library is broken. Which compiler are you using ?

Share this post


Link to post
Share on other sites
read the thread :P

I use .net 2002, does anyone know how to use the 2002 IDE for the 2003 toolkit? I can't find any of the websites telling me how right now.

Share this post


Link to post
Share on other sites
Did you examine this line:
Quote:
unresolved external symbol _use_Q_snprintf_instead_of_sprintf
Obviously, your stringstream implementation internally uses sprintf() to perform the conversion, which is something your runtime library doesn't want you to.

You probably have your runtime library components mixed up between two different versions, products or vendors.
- Are you, by any chance, using STLport in VS.NET 2002 or some other STL replacement library ?
- Do you have other C++ compilers (including older/newer versions of VisualStudio) installed on this system ? (your include paths might incorporate the other compiler's directories)

-Markus-

Share this post


Link to post
Share on other sites
Yeah I did, and I had no idea why it was complaining about that.

to answer you questions
1. no, I am not using any STL replacment libraries
2. well now I do :P, I didn't before this.

Share this post


Link to post
Share on other sites
Well, one (obvious? [grin]) way to fix that would be to dig in and hack your standard library headers (the implementation is all in there). [wink]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this