> Because of the promotion rules these should use the unmodified printf()
> format specifiers %d/i/o/u/x except for the 64-bit types which need the
> %ll modifier, even when building for Windows.
Rather than making assumptions about the mapping to platform-dependent types we should leave these things up to the standard library. Also technically long long is part of C99/C++11.
> #ifndef EPRIuSIZE
> # if defined(vxWorks)
> # define EPRIuSIZE "lu"
> # else
> # define EPRIuSIZE "zu"
> # endif
Can we safely assume that pre-C99/C++11 compilers are only used for VxWorks? To be safe, I would suggest to start using %zu with EPICS 7.1. If we do so no EPICS-specific macro is required.
Using %zu as well as the format-string macros for fixed-size integer
types defined by inttypes.h seems consequent and the most portable
solution to me (with EPICS 7.1). Should a new format specifier make it
into the C/C++ standard we can safely replace the ugly macros.
All this is probably affecting support modules more than Base since
fixed-size integer types and printf aren't used that heavily in Base.
You received this bug notification because you are a member of EPICS
Core Developers, which is subscribed to EPICS Base.
Matching subscriptions: epics-core-list-subscription
portable printf() spec for size_t, long long, and others
Status in EPICS Base:
I've been in the habit of using '%lld' and '%zu' to print 'long long'
and 'size_t' respectively. However, the windows world needs '%I64d'
and '%Iu' instead. It would be nice to have compatibility macros for
stdint.h/inttypes.h has a convention for this for the standard fixed
width types. eg. PRIx32 for 'uint32_t'. This is used like:
> printf("%"PRIx32"\n", (uint32_t)42);
To manage notifications about this bug go to:
- Navigate by Date:
Error message binding socket 5076 on vxWorks Mark Rivers via Core-talk
Re: Error message binding socket 5076 on vxWorks Michael Davidsaver via Core-talk
- Navigate by Thread:
[Bug 1740426] Re: portable printf() spec for size_t, long long, and others Martin Konrad via Core-talk
EPICS 7, pvAccess & static build Torsten Bögershausen via Core-talk