Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: ollydbg on October 30, 2022, 06:45:46 am

Title: using llu instead of d for the Format
Post by: ollydbg on October 30, 2022, 06:45:46 am
I see an alert message when C::B start in the latest rev 12996.

This patch try to fix it.

Code
From 63c1c31529667c9985c4ab96087ef1bf591f0e70 Mon Sep 17 00:00:00 2001
From: asmwarrior <a@b.com>
Date: Sun, 30 Oct 2022 13:39:30 +0800
Subject: use the %llu for unsigned long long value, otherwise, an alert will
 happen


diff --git a/src/sdk/toolsmanager.cpp b/src/sdk/toolsmanager.cpp
index 616fb2d1..ac6395bf 100644
--- a/src/sdk/toolsmanager.cpp
+++ b/src/sdk/toolsmanager.cpp
@@ -264,7 +264,7 @@ void ToolsManager::LoadTools()
 
         AddTool(&tool, false);
     }
-    Manager::Get()->GetLogManager()->Log(wxString::Format(_("Configured %d tools"), m_Tools.GetCount()));
+    Manager::Get()->GetLogManager()->Log(wxString::Format(_("Configured %llu tools"), m_Tools.GetCount()));
 }
 
 void ToolsManager::SaveTools()


My question is: why the old F() function does not show the alert message box?
Title: Re: using llu instead of d for the Format
Post by: Miguel Gimenez on October 30, 2022, 09:39:19 am
This a diagnostic from the compiler (or wxWidgets), it knows how printf() works but nothing about F().

I did not see this because I am working with 32 bits, I will fix it in trunk.
Title: Re: using llu instead of d for the Format
Post by: Miguel Gimenez on October 30, 2022, 09:51:40 am
Fixed in r12997 (https://sourceforge.net/p/codeblocks/code/12997/).
Title: Re: using llu instead of d for the Format
Post by: PB on October 30, 2022, 04:45:25 pm
Fixed in r12997 (https://sourceforge.net/p/codeblocks/code/12997/).

Just a nitpick, sorry. IMO, the correct solution would be to use "%zu". %zu is the natural formatter for size_t returned by GetCount() / size() methods of std(-like) containers,  hence no cast is required and the formatter works regardless of 32/64-bit builds. It has been supported by wxWidgets since a long time.
Title: Re: using llu instead of d for the Format
Post by: Miguel Gimenez on October 30, 2022, 06:24:58 pm
Corrected in r12998, thank you.
Title: Re: using llu instead of d for the Format
Post by: ollydbg on October 31, 2022, 06:26:00 am
@PB, @Miguel Gimenez

Thanks.