Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two *printf size warnings reported on ILP32 platforms. #1364

Merged
merged 1 commit into from Oct 24, 2020

Conversation

nwc10
Copy link
Contributor

@nwc10 nwc10 commented Oct 23, 2020

In debugserver.c, handle_id is 64 bit, so use PRId64.

In the profiler, we print out the difference between two pointers. This has
the type ptrdiff_t. It seems that on most platforms that ptrdiff_t is a
typedef for long. However, on (at least) arm32 and sparc32 it is a typedef
for int (despite int and long being the same size on these platforms).
Hence *printf format checking warns about a mismatch between types.
Oh so helpful.

C11 provides a size modifier t for ptrdiff_t, but we're still stuck in
the century of the fruitbat, so we can't use that. So just cast to long.

In debugserver.c, handle_id is 64 bit, so use PRId64.

In the profiler, we print out the difference between two pointers. This has
the type ptrdiff_t. It seems that on most platforms that ptrdiff_t is a
typedef for long. However, on (at least) arm32 and sparc32 it is a typedef
for int (despite int and long being the same size on these platforms).
Hence *printf format checking warns about a mismatch between types.
Oh so helpful.

C11 provides a size modifier `t` for ptrdiff_t, but we're still stuck in
the century of the fruitbat, so we can't use that. So just cast to long.
@nwc10 nwc10 merged commit 3c3a24b into master Oct 24, 2020
@nwc10 nwc10 deleted the ILP32-printf-warnings branch October 24, 2020 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants