Nuklear icon indicating copy to clipboard operation
Nuklear copied to clipboard

Add printf formatting macros for nk data types

Open PROP65 opened this issue 11 months ago • 4 comments

Adds macros from formatting the nk data types

Macro Type
NK_FMT_CHAR nk_char
NK_FMT_UCHAR nk_uchar
NK_FMT_BYTE nk_byte
NK_FMT_SHORT nk_short
NK_FMT_USHORT nk_ushort
NK_FMT_INT nk_int
NK_FMT_UINT nk_uint
NK_FMT_SIZE nk_size
NK_FMT_PTR nk_ptr

This won't completely prevent issues like #727 but it should help.

Needs to be tested on Windows.

PROP65 avatar Feb 08 '25 06:02 PROP65

Here's a test program to check for warnings.

https://gist.github.com/PROP65/88cf2ec23a5052350f2e79857dd9fd8e

PROP65 avatar Feb 08 '25 07:02 PROP65

Seems like a good solution. Those warnings have been pretty annoying in the build sometimes.

RobLoach avatar Feb 10 '25 17:02 RobLoach

IS this good to go, now?

RobLoach avatar Oct 25 '25 13:10 RobLoach

Is this really necessary?

Nuklear does not depend on exact-int-size printf formatting anywhere in its sources, only demos and examples really need it. There is roughly one place in a library where a simple formatting (%s/%d/%f/etc) is being used, and this PR is not even applying to it. Demos/examples are relaxed from C89 rule and there would be nothing wrong if you simply include <inttypes.h> somewhere inside of demo/common/overview.c. In fact most of those already require C99, and this is even mentioned here. Adding all those macros into library headers brings so much complexity and possible issues. I don't believe it's worth it.

@RobLoach Don't get me wrong, but I don't think this should be ever merged. The linked issue (https://github.com/Immediate-Mode-UI/Nuklear/issues/727) is only about demo/common/overview.c. Fixing it by adding all those symbols to the library is an over-kill.

sleeptightAnsiC avatar Nov 17 '25 19:11 sleeptightAnsiC