#include typedef struct { int fn1, fn; void * next; } Fib; #define FibCtor { 1, 0, NULL } Fib * comain( Fib * f ) { if ( __builtin_expect(f->next != 0, 1) ) goto *f->next; f->next = &&s1; for ( ;; ) { return f; s1:; int fn = f->fn + f->fn1; f->fn1 = f->fn; f->fn = fn; } } int main() { Fib f1 = FibCtor, f2 = FibCtor; for ( int i = 0; i < 10; i += 1 ) printf( "%d %d\n", comain( &f1 )->fn, comain( &f2 )->fn ); } // Local Variables: // // tab-width: 4 // // compile-command: "gcc-8 Fib3.c" // // End: //