1. 24
  1.  

  2. 1

    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.

    1. 1

      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.

      1. 1

        I believe the solution is to declare without a prototype (() rather than (...)).

        1. 1

          No, declared without a prototype uses the K&R calling convention, which has several downsides:

          • It’s completely unspecified and does the wrong thing.
          • It doesn’t work at all in C++ (C++ removed it and declared () to mean the same as (void))
          • It doesn’t work in C23 (C23 finally removed it because it was stupid and most people using it did not mean to).

          That said, it looks like I misread the blog this morning and they’re actually doing the right thing.

          1. 2

            C23 finally removed it

            Indeed. I remain shocked and baffled that that change made it through the committee.

      2. 1

        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.