Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to printf 64 bit data type

248 views
Skip to first unread message

Phil

unread,
Sep 28, 2001, 7:20:13 PM9/28/01
to
Hi All,

How do you use format in printf to print a variable of type long long
(64 bit)? I break it down to two chunks of 32 bit to print but it's
painful when you have the code for multiple platforms. Thanks

Phil

David Given

unread,
Oct 1, 2001, 6:24:45 AM10/1/01
to
In article <a1ef1bab.01092...@posting.google.com>,

The usual standard is to use the ll modifier; for example, %llX. However,
it's entirely possible that VxWorks' printf() doesn't understand that.

--
David Given
Tao Group Ltd.

Ward Horner

unread,
Oct 1, 2001, 9:13:09 PM10/1/01
to
VxWorks 5.4 doesn't support printing of long long ints.

The only way I have solved that problem is to break the long long into 32
bit values (by using an int pointer) and print each one side by side. Of
course that only works if you are printing in hex and format to print
leading zeros (%08h).

Alternatively you could try to obtain the source for that library from your
local FAE and modifying it.

Ward

=========================================================
T h e P T R G r o u p, I n c.
=========================================================
Ward Horner
Manager, Consulting Services and Training
wa...@ThePTRGroup.com
=========================================================
Embedded, Real-Time Solutions and Training
Visit us on the web at http//www.ThePTRGroup.com
http://www.ThePTRGroup.com/buildpage.php/services
=========================================================

vxwork...@tao-group.com (David Given) wrote in news:d9g9p9.7c9.ln@
172.16.100.66:

Ward Horner

unread,
Oct 1, 2001, 9:14:12 PM10/1/01
to
VxWorks 5.4 doesn't support printing of long long ints.

The only way I have solved that problem is to break the long long into 32
bit values (by using an int pointer) and print each one side by side. Of
course that only works if you are printing in hex and format to print
leading zeros (%08h).

Alternatively you could try to obtain the source for that library from your
local FAE and modifying it.

Ward

=========================================================
T h e P T R G r o u p, I n c.
=========================================================
Ward Horner
Manager, Consulting Services and Training
wa...@ThePTRGroup.com
=========================================================
Embedded, Real-Time Solutions and Training
Visit us on the web at http//www.ThePTRGroup.com
http://www.ThePTRGroup.com/buildpage.php/services
=========================================================

vxwork...@tao-group.com (David Given) wrote in news:d9g9p9.7c9.ln@
172.16.100.66:

> In article <a1ef1bab.01092...@posting.google.com>,

Mario Semo

unread,
Oct 1, 2001, 3:57:25 AM10/1/01
to
Hello,

just in case you have MSVC++ for WinNT. Look for the source code xtoa.c.
(its on the CDROM).
i added the following to the begin of xtoa.c:

#define __int64 long long
#define __stdcall
/*#include <lccompiler.h>*/
#include <LCoosCRTFix.h> // see end of mail
#include <LCoosBase.h> // which includes my prototypes
#include <errno.h>

then i changed some minor parts:

/* #include <cruntime.h> */
#include <stdlib.h>
#include <limits.h>

Then i #if 0 // !! from:

#if 0
static void __cdecl xtoa (
...
up to


#endif
#ifndef _NO_INT64
static int __stdcall x64toa ( /* stdcall is faster and smaller... Might
as well use it for the helper. */

and finally i added at the end:

/*@FUNC*********************************************************************
**
** 00-09-21 | MS | CREATED
****************************************************************************
*/
unsigned LCoosEXPORT LCoosSYSLINK ullToStr( LC_ULLINT ull, char *pStrIn, int
pStrInSize,unsigned radix)
{
if (!x64toa(ull,pStrIn,radix,0,pStrInSize))
return 0;
return ENOMEM;
}
/*@FUNC*********************************************************************
**
** 00-09-21 | MS | CREATED
****************************************************************************
*/
unsigned LCoosEXPORT LCoosSYSLINK sllToStr( LC_SLLINT sll, char *pStrIn, int
pStrInSize,unsigned radix)
{
if (!x64toa((unsigned __int64)sll,pStrIn,radix,(radix == 10 && sll <
0),pStrInSize))
return 0;
return ENOMEM;
}

(export and syslink are empty for vxWorks, LC_SLLINT is signed long long).

regarding lcooscrtfix

i can exactly remember what i needed this for. it contains

#include <stdio.h>
#include <usrlib.h>

#define strnset memset

hope thats help to write a portable long long to string conversion. (i see
no other chance to get long longs printed portable as long as windriver does
no fix their code).

--
regards, Mario Semo. http://www.kirchnersoft.com
Phil <phuc....@intel.com> wrote in message
news:a1ef1bab.01092...@posting.google.com...

0 new messages