Nuklear icon indicating copy to clipboard operation
Nuklear copied to clipboard

nk_do_property() uses nk_strtod() instead of NK_STRTOD()

Open sleeptightAnsiC opened this issue 1 month ago • 4 comments

You can provide your own definition of NK_STRTOD(), but nk_do_property() will ignore this and still use internal nk_strtod() instead of user-provided macro:

https://github.com/Immediate-Mode-UI/Nuklear/blob/fcd64f85e54b9d35eee13347748d70fa4d2e134e/src/nuklear.h#L3818-L3821

https://github.com/Immediate-Mode-UI/Nuklear/blob/fcd64f85e54b9d35eee13347748d70fa4d2e134e/src/nuklear_property.c#L283-L287

Should be an easy fix, unless there are more issues like this one, or if there is some hidden dependency issue that I missed.

sleeptightAnsiC avatar Nov 04 '25 19:11 sleeptightAnsiC

Thahnks for putting together these follow up issues.

RobLoach avatar Nov 06 '25 17:11 RobLoach

This indeed resolves the inconsistency that currently exists in Nuklear. In the code, the NK_PROPERTY_FLOAT branch calls nk_strtof: https://github.com/Immediate-Mode-UI/Nuklear/blob/fcd64f85e54b9d35eee13347748d70fa4d2e134e/src/nuklear_property.c#L278-L282

nk_strtof implementation is: https://github.com/Immediate-Mode-UI/Nuklear/blob/fcd64f85e54b9d35eee13347748d70fa4d2e134e/src/nuklear_util.c#L224-L232

Therefore, in the NK_PROPERTY_DOUBLE branch we should definitely call NK_STRTOD. This will ensure consistent behavior between the float and double property handling.

PavelSharp avatar Nov 07 '25 16:11 PavelSharp

Note: be careful when fixing this or https://github.com/Immediate-Mode-UI/Nuklear/issues/256: nk_strtod() is missing a #ifndef NK_STRTOD guard.

sleeptightAnsiC avatar Nov 07 '25 17:11 sleeptightAnsiC

Note: make sure to also deal with this at the same time: https://github.com/Immediate-Mode-UI/Nuklear/issues/700

sleeptightAnsiC avatar Nov 18 '25 16:11 sleeptightAnsiC