Radar ·
Simon Tatham's coroutine trick in standard C
Simon Tatham, creator of PuTTY, describes a portable way to simulate coroutines in standard C using a switch/case technique, Duff's Device and __LINE__, without threads or assembly.
According to the briefing published on 29 October 2026, Simon Tatham, creator of PuTTY, describes how to simulate coroutines in standard C using the switch/case technique behind Duff's Device combined with __LINE__. The idea is a portable, macro-based way to write resumable functions without threads or assembly. The post states that PuTTY still uses versions of this trick in its SSH protocol code.
To consult the original, search for the author's post by its title and his name in a search engine, and check the date, the example code and any caveats before reusing any snippet. Because the topic is C programming, there is no direct platform use. If you use an AI assistant to study the material, do not paste proprietary code, credentials or personal data into the prompt.
Original source: Truque de corrotinas de Simon Tatham em C padrão