portable printf() spec for size_t, long long, and others
Bug #1740426 reported by
mdavidsaver
This bug affects 2 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
EPICS Base |
Triaged
|
Wishlist
|
mdavidsaver |
Bug Description
I've been in the habit of using '%lld' and '%zu' to print 'long long' and 'size_t' respectively.
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(
http://
edit 2022: As Mark points out, Windows supports %zu. The remaining holdout is vxWorks...
description: | updated |
To post a comment you must log in.
Considering the fact that issues related to these constructs are popping up again and again I would also like to see this addressed.
Fixed-width integer types are provided by stdint.h since C99 (https:/ /en.wikipedia. org/wiki/ C_data_ types#stdint. h). In the case of GCC it seems like the standard library ships with this feature since 4.5 (see https:/ /gcc.gnu. org/c99status. html). MSVC includes the required macros in 2015+ (https:/ /docs.microsoft .com/en- us/cpp/ standard- library/ cstdint? view=vs- 2015), according to StackOverflow even since 2010 (see https:/ /stackoverflow. com/questions/ 126279/ c99-stdint- h-header- and-ms- visual- studio). Not sure about clang.
Considering the fact that the 7.0 branch needs to support VxWorks 6 with GCC 4.3 we can only implement this in 7.1 (assuming that we want to stay away from implementing/ maintaining these macros in EPICS Base).