Looks like an interesting library, thanks for the hint. I will have a close look at it. Another one that appeared last year (but was developed over ten years) is https://github.com/frang75/nappgui_src.
The conversion of Objective-C to C made me cringe because the message send function is declared variadic but uses the non-variadic call8mg convention. It must be cast to a function pointer of the correct type before being called to avoid undefined behaviour. You also need to be careful with things that return floating point values or structures (the 32-bit x86 version could leave the x87 stack in an undefined state and crash if you did this wrong). On A64 Apple platforms, the variadic and non-variadic calling conventions are different, so failing to do this cast will fail in very exciting ways. A few years ago I wrote a trivial C++ variadic template that did the right thing based on the arguments but doing the same with C macros is painful.
I think fenster_time() should be using CLOCK_MONOTONIC instead of CLOCK_REALTIME, since it is being used for FPS limiting. The value of CLOCK_REALTIME will jump if you adjust your computer clock, causing weird behaviour in applications that build delays off of it.
Looks like an interesting library, thanks for the hint. I will have a close look at it. Another one that appeared last year (but was developed over ten years) is https://github.com/frang75/nappgui_src.
The conversion of Objective-C to C made me cringe because the message send function is declared variadic but uses the non-variadic call8mg convention. It must be cast to a function pointer of the correct type before being called to avoid undefined behaviour. You also need to be careful with things that return floating point values or structures (the 32-bit x86 version could leave the x87 stack in an undefined state and crash if you did this wrong). On A64 Apple platforms, the variadic and non-variadic calling conventions are different, so failing to do this cast will fail in very exciting ways. A few years ago I wrote a trivial C++ variadic template that did the right thing based on the arguments but doing the same with C macros is painful.
I believe the solution is to declare without a prototype (
()
rather than(...)
).No, declared without a prototype uses the K&R calling convention, which has several downsides:
()
to mean the same as(void)
)That said, it looks like I misread the blog this morning and they’re actually doing the right thing.
Indeed. I remain shocked and baffled that that change made it through the committee.
I think
fenster_time()
should be usingCLOCK_MONOTONIC
instead ofCLOCK_REALTIME
, since it is being used for FPS limiting. The value ofCLOCK_REALTIME
will jump if you adjust your computer clock, causing weird behaviour in applications that build delays off of it.