Jump to content
  • Advertisement
Sign in to follow this  
kappa

Does anyone know why this does not work?

This topic is 4860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
It works fine with my compiler, which compiler are you using, if you are using vc++ 6.0 then it could be your compiler and time to update :D

Share this post


Link to post
Share on other sites
Have you made sure your including the correct files, you need

#include <string>
#include <sstream>

That might cause that prob

Share this post


Link to post
Share on other sites
I have them both included, downloaded the 2003 toolkit and see if it works with that.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!