gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: long long unsigned on 32-bit machines


From: Michael J. Tubby B.Sc. MIET
Subject: Re: long long unsigned on 32-bit machines
Date: Mon, 27 Jan 2020 20:59:19 +0000
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1



On 27/01/2020 20:24, Gary E. Miller wrote:
Yo Hal!

On Sat, 25 Jan 2020 23:42:21 -0800
Hal Murray <address@hidden> wrote:

There are at least 2 ways to fix that.

There are a bunch of symbols to handle this mess: PRIu64 and friends
are defined in /usr/include/inttypes.h  It's

/usr/include/inttypes.h:# define PRIu64         __PRI64_PREFIX "u"
I tried that.  A bunch of older compilers barf on PRIu64.  Yes, it is POSIX
2001, but implementation is still marginal.

You can cast the thing you want to print to (unsigned) long long and
use ll.

printf("%llu"\n", (unsigned long long)t);
What is what I had to convert the PRIu64 back to for things to compile.

Which is why all of the code that we have developed in house since 1990 uses #defines like

#define UC unsigned char
#define US unsigned short
#define UL unsigned long
#define ULL unsigned long long

so that we can globally update our code with:

#define UC uint8_t
#define US uint16_t
#define UL uint32_t
#define ULL uint64_t

or whatever flavour we need for irksome compilers or build environments ;-)

... and there are a few 64-bit environments that return sizeof(time_t) = 4 which is worrisome ;-(

Mike

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
	address@hidden  Tel:+1 541 382 8588

	    Veritas liberabit vos. -- Quid est veritas?
    "If you can't measure it, you can't improve it." - Lord Kelvin

--

Michael J Tubby B.Sc. (Hons) MIET / Technical Director
Email: address@hidden
Direct: +44 (0)1905 752892
Mobile: +44 (0)7973 225144

Thorcom Systems Limited
Office: +44 (0)1905 756 700
Unit 4, 96B Blackpole Trading Estate West, Worcester, WR3 8TJ, England, UK
Registered in England & Wales 02704696 / VAT Number GB487925681

This email and any attachments to it may be confidential or legally privileged and are intended solely the individual to whom it is addressed.
If you are not the intended recipient of this email, you must not take any action based upon its contents or disclose its contents to any third-party.
This email footer is intended to identify the sender and does not constitute a signature or agreement to enter into any form of legally binding contract.
While the author has taken reasonable care in the preparation of this email Errors and Omissions Excepted (E&OE).
Any views or opinions expressed are those of the author and do not necessarily represent those of Thorcom Systems Limited.
Please contact the sender if you believe you have received this email in error.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]