CIR Playground
Load example...
CIR on GitHub
Input
Run
#include <stdio.h> #include <stdlib.h> #include <cir.h> // include compiler API // Reads a file and returns it as a string constant static CirCodeId readFile(char *path) { FILE *fp = fopen(path, "r"); if (!fp) cir_fatal("failed to open %s", path); fseek(fp, 0, SEEK_END); size_t len = ftell(fp); fseek(fp, 0, SEEK_SET); char *buffer = malloc(len + 1); fread(buffer, len, 1, fp); buffer[len] = 0; fclose(fp); return CirCode_ofExpr(CirValue_ofString(buffer, len + 1)); } int main(void) { puts(@readFile("/usr/include/cir.h")); return 0; }
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