Show HN: Canon-C – a semantic C library

(github.com)

2 points | by Fikoko 8 hours ago ago

3 comments

  • oguz-ismail2 7 hours ago ago

    Nit pick, but

    >FILE* f = fopen(path, "rb");

    >...

    >if (fseek(f, 0, SEEK_END) != 0) return option_charp_none();

    >long len = ftell(f);

    does ISO C guarantee this'll work these days? How come there's no fread+realloc fallback?

    • Fikoko 7 hours ago ago

      Good catch! You’re right, ftell + fseek isn’t guaranteed to work for all files in ISO C, especially very large or non-seekable ones. In practice, for typical binary files it works fine, but I’ll add a note in the docs. I will consider a fallback using fread + realloc for full portability.

  • undefined 8 hours ago ago
    [deleted]