Immediate-Mode-UI / Immediate-Mode-UI/Nuklear

Wrong format string specifier for size_t argument in demo/overview.c when compiling on newer compilers

Open
#131 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
11.4k
Forks
686
Avg merge
4d 1h
Merged PRs (30d)
3

Description

I get warnings when compiling some of the demo files in VS2019:

> 1>demo\overview.c(403,33): warning C4477: 'sprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
> 1>demo\overview.c(403,33): message : consider using '%zu' in the format string
> 1>demo\overview.c(415,33): warning C4477: 'sprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
> 1>demo\overview.c(415,33): message : consider using '%zu' in the format string

There's a similar warning in clang as well.

Seems that using the correct format specifier wouldn't be compatible with C89/C90, so this isn't quite as trivial as the fix the warning suggests.

Contributor guide

Open the contributing guide

Research direction

Inspect demo/overview.c at the reported lines 403 and 415, then compare the format-string requirements in VS2019 and clang with the project's C89/C90 compatibility constraint. Done means the size_t warnings are addressed without violating the stated compatibility requirement.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.