Problem with wxString::Format and uint64_t Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
DanL
Experienced Solver
Experienced Solver
Posts: 63
Joined: Wed Feb 14, 2007 7:32 pm

Problem with wxString::Format and uint64_t

Post by DanL » Wed Apr 04, 2007 5:01 am

Hi everyone,

I'm having bit of a problem getting 64-bit values to display properly using wxString::Format. I am not running on a 64-bit platform if that has anything to do with it. My code is as follows:

Code: Select all

uint64_t    TotalNumberOfSamplesPerChannel = 99999999999999;
(*WxMemo1) << wxString::Format("%" wxLongLongFmtSpec "u",F.TotalNumberOfSamplesPerChannel);
This prints "%I64u". I gathered the information to format the string from here:http://forums.wxwidgets.org/viewtopic.php?t=6310

I've also gotten it to print out 2764472319. But that's not as big as 99999999999999 :wink:.

I have a feeling this has something to do with the fact that I'm not actually running on a 64-bit platform, but I had thought that no matter what platform you're on, you could still use 64-bit values.

BTW, I'm using wxDev-C++ 6.10-2. Thanks!

tan
Moderator
Moderator
Posts: 1471
Joined: Tue Nov 14, 2006 7:58 am
Location: Saint-Petersburg, Russia

Post by tan » Wed Apr 04, 2007 5:24 am

Hi,
did you try wxLongLong::ToString()?
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10

tan
Moderator
Moderator
Posts: 1471
Joined: Tue Nov 14, 2006 7:58 am
Location: Saint-Petersburg, Russia

Post by tan » Wed Apr 04, 2007 6:36 am

Hi,
this code works on WinXP 32 bit (celeron):

Code: Select all

   wxLongLong_t TotalNumberOfSamplesPerChannel = 99999999999999;
   wxString res = wxString::Format("%" wxLongLongFmtSpec "u", TotalNumberOfSamplesPerChannel);
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10

lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel » Wed Apr 04, 2007 11:25 am

I have a feeling it's your compiler (which I think is MingW). If you are using MingW then it should work. http://msdn2.microsoft.com/en-us/librar ... S.80).aspx.

The other alternative you CAN try is that instead of using uint64_t you can use "unsigned long long" or "unsigned __int64".

Joel

DanL
Experienced Solver
Experienced Solver
Posts: 63
Joined: Wed Feb 14, 2007 7:32 pm

Post by DanL » Wed Apr 04, 2007 3:05 pm

Hmm, it seems to be working just fine on a different computer now. I originally had the problem under MinGW on an Athlon 64 (in 32-bit mode). At the moment, I'm on a Pentium 4 and don't have any problems. I'll have to look at it again on the other computer.

DanL
Experienced Solver
Experienced Solver
Posts: 63
Joined: Wed Feb 14, 2007 7:32 pm

Post by DanL » Thu Apr 05, 2007 4:24 am

Well I upgraded to wxDev-C++ 6.10-2 and now I don't see this problem. Don't know what happened there! Thanks for the help everyone.

lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel » Thu Apr 05, 2007 10:13 am

It would be good to accept your own answer to mark it as "solved". (or if you're generous you can mark any of our answers too :))

Joel

Post Reply