以十六进制打印uin32_t [英] printing uin32_t in hexadecimal
问题描述
嗨。
我有以下代码:
uint32_t quadlet = 0x12345678;
printf(" quadlet = %08X \ n",quadlet);
我的编译器给出了以下警告:unsigned int format,uint32_t
arg(arg 2)
我可以使用任何formtat吗? %08uX?
谢谢
Maxime
Hi.
I have the following code:
uint32_t quadlet = 0x12345678;
printf("quadlet = %08X\n", quadlet);
my compiler give me the following warning: unsigned int format, uint32_t
arg (arg 2)
Is there any formtat I can use? %08uX ?
thanks
Maxime
推荐答案
Maxime Barbeau写道:
Maxime Barbeau wrote:
嗨。
我有以下代码:
uint32_t quadlet = 0x12345678;
printf(" quadlet =%08X \ n",quadlet);
我的编译器给出了以下警告:unsigned int format,uint32_t
arg(arg 2)
是我可以使用任何formtat吗? %08uX?
Hi.
I have the following code:
uint32_t quadlet = 0x12345678;
printf("quadlet = %08X\n", quadlet);
my compiler give me the following warning: unsigned int format, uint32_t
arg (arg 2)
Is there any formtat I can use? %08uX ?
%lx
Tom
%lx
Tom
开星期五,2004年8月13日15:11格林尼治标准时间,Tom St Denis< to ******** @ iahu.ca>写道:
On Fri, 13 Aug 2004 15:11 GMT, Tom St Denis <to********@iahu.ca> wrote:
Maxime Barbeau写道:
Maxime Barbeau wrote:
我有以下代码:
uint32_t quadlet = 0x12345678;
printf(" quadlet =%08X \\ \\ n,quadlet;
我的编译器给了我以下警告:unsigned int format,uint32_t
arg(arg 2)
是否有任何formtat我可以使用? %08uX?
I have the following code:
uint32_t quadlet = 0x12345678;
printf("quadlet = %08X\n", quadlet);
my compiler give me the following warning: unsigned int format, uint32_t
arg (arg 2)
Is there any formtat I can use? %08uX ?
%lx
%lx
否,%lx不完全正确。 %lx期望一个unsigned long。
尽管unsigned long和uint32_t在许多
系统上具有相同的表示,但它们绝对没有要求。我们知道
unsigned long至少是32位,所以更合适的方法是使用%lx并将参数转换为unsigned long。这样,如果无符号
长,比方说64位,printf()就不会抓住额外的32位垃圾了
堆栈(或者其他任何方法)你的实现恰好用于
参数传递。
Chris
No, %lx is not completely correct. %lx expects an unsigned long.
Although unsigned long and uint32_t have the same representation on many
systems, there''s absolutely no requirement for them to. We do know that
unsigned long is at least 32 bits, so a more proper method would be to
use %lx and cast the argument to unsigned long. That way, if unsigned
long is, say, 64 bits, printf() won''t grab an extra 32 bits of junk off
the stack (or whatever method your implementation happens to use for
argument passing).
Chris
Maxime Barbeau写道:
Maxime Barbeau wrote:
我有以下代码:
uint32_t quadlet = 0x12345678;
printf(" quadlet =%08X \ n",quadlet);
我的编译器给出了以下警告:unsigned int format,
uint32_t arg(arg 2)
我可以使用任何formtat吗? %08uX?
I have the following code:
uint32_t quadlet = 0x12345678;
printf("quadlet = %08X\n", quadlet);
my compiler give me the following warning: unsigned int format,
uint32_t arg (arg 2)
Is there any formtat I can use? %08uX ?
使用uint32_t需要#include< stdint.h>和一个C99编译器
系统。你可能也没有。
-
Chuck F(cb********@yahoo.com)(cb ********@worldnet.att.net)
可用于咨询/临时嵌入式和系统。
< http://cbfalconer.home。 att.net>使用worldnet地址!
Using uint32_t requires #include <stdint.h> and a C99 compiler
system. You probably don''t have either.
--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
这篇关于以十六进制打印uin32_t的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!