how printf unsigned long long uint_64

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

how printf unsigned long long uint_64

跳至解决方案
2,663 次查看
RuiFaria
Contributor III

Hi

 

Anyone knows how can i printf a unsigned long long (uint_64) variable?

 

uint_32 var32  = 0;

uint_64 var64 = 0;

 

printf("var32 = %lu \n", var32);

printf("var64 = %?? \n", var64);  // Question ??

 

Note: %llu doesn't work for unsigned long long variables

 

 

I am using M52259Demo Board, MQX 3.6.2 and CodeWarrior Coldfire Classic 7.2.1 with C++ Compiler.

 

thanks in advance

0 项奖励
回复
1 解答
1,848 次查看
RuiFaria
Contributor III

Hi,

 

It is a good ideia but it is not exactly what i intend. :smileyhappy:

 

I reported this subject to Support Center and the answer was:

 

"long long printf support is currently not supported by MQX printf function – we have it logged in our bug tracking system,  not sure if it will be solved for verson 3.7.0 which is launched in March 31, but definitely for 3.8.0."

 

Thanks for your attention.

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,848 次查看
DavidS
NXP Employee
NXP Employee

Hi RuiFaria,

I haven't tried this so am just suggesting one idea.

You might do something like:

 

 uint_64 var64=0xfeedbeefdefacbad;
 uint_32 tmp32h=var64>>32;
 uint_32 tmp32l=(var64<<32)>>32;

 printf("var60=0x%08X%08X\n", tmp32h, tmp32l);

 

Hope this might work :smileyhappy:

Regards,

David

1,848 次查看
DavidS
NXP Employee
NXP Employee

One more try:

 

 uint_64 var64=0xfeedbeefdefacbad;
 uint_32 tmp32h=(uint_32)(var64>>32);
 uint_32 tmp32l=(uint_32)((var64<<32)>>32);

 printf("var64=0x%08X%08X\n", tmp32h, tmp32l);
 printf("var64=0x%08X%08X\n", (uint_32)(var64>>32), (uint_32)((var64<<32)>>32));

 

Output looked like:

var64=0xFEEDBEEFDEFACBAD
var64=0xFEEDBEEFDEFACBAD

1,849 次查看
RuiFaria
Contributor III

Hi,

 

It is a good ideia but it is not exactly what i intend. :smileyhappy:

 

I reported this subject to Support Center and the answer was:

 

"long long printf support is currently not supported by MQX printf function – we have it logged in our bug tracking system,  not sure if it will be solved for verson 3.7.0 which is launched in March 31, but definitely for 3.8.0."

 

Thanks for your attention.

0 项奖励
回复