> On Oct 17, 2014, at 3:22 AM, [email protected] wrote:
>
> Hi,
> I tried to print a UINT64 value as follows and hoped to get output
> “0x1122334455667788”:
> {
> UINT64 Value = 0x1122334455667788;
> Print(L“0x%.16x”, Value);
> }
>
In the EDK x was a UINTN. This caused issues with some compilers due to C
integer promotion, so in the edk2 it was changed to int.
https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Library/PrintLib.h
- L, l
- The number being printed is size UINT64. Only valid for types X, x,
and d.
If this flag is not specified, then the number being printed is size
int.
- x
- The argument is an unsigned hexadecimal number. The characters used
are 0..9 and
A..F. If the flag 'L' is not specified, then the argument is assumed
to be size int. This does not follow ANSI C.
- X
- The argument is an unsigned hexadecimal number and the number is padded
with
zeros. This is equivalent to a format string of "0x". If the flag
'L' is not specified, then the argument is assumed to be size int.
This does not follow ANSI C.
I would point out in both cases your code is not correct as UINTN != UINT64.
The only portable way to do UINT64 in the EDK and edk2 is %lx.
Thanks,
Andrew Fish
> The actual output is “0x0000000055667788” though. The leading 4 bytes seem to
> get lost in cast to unsigned int in BasePrintLibVSPrint, line 320.
> Seehttps://github.com/tianocore/edk2/blob/master/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c
>
> <https://github.com/tianocore/edk2/blob/master/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c>
>
> As a workaround I now use Print(L“0x%.8x%.8x”, Value >> 32, Value) but I
> would prefer to use Print(L“0x%.16x”, Value).
>
> Thanks and Regards,
> Stefan
> ------------------------------------------------------------------------------
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho_______________________________________________
> <http://p.sf.net/sfu/Zoho_______________________________________________>
> edk2-devel mailing list
> [email protected] <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
> <https://lists.sourceforge.net/lists/listinfo/edk2-devel>
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel