CIR Playground
Load example...
CIR on GitHub
Input
Run
// This is an equivalent program to 06, but written using CIR compile-time // functions. #include <cir.h> #include <cirq.h> int printf(const char *, ...); static CirCodeId repeat(int n, CirCodeId code) { return @CirQ(({ for (int i = 0; i < @CirAQ(n); i = i + 1) @CirAQ(code); })); } int main(void) { int i = 20; @repeat(3, printf("The value of i is %d\n", i)); return 0; } // If you squint carefully at the CIR output, you will see that CIR will treat // the two `i` variables as two different variables. // // The CIR output, when compiled, will give the correct output: // // The value of i is 20 // The value of i is 20 // The value of i is 20
stdout
stderr
Load Example...
×
00 - Compile-time fibonacci
01 - Inline Repeat
02 - Compile-time strtok
03 - Does a code call a function
04 - C Preprocessor identifiers may be accidentally shadowed
05 - CIR identifiers won't be accidentally shadowed
06 - C Preprocessor accidental capture of symbols
07 - CIR won't accidentally capture symbols
08 - bf-to-C (low level ver)
09 - bf-to-C (with quote-antiquote)
10 - async-await
11 - Embed an external file
12 - zlib