Hacker News new | ask | show | jobs
by david2ndaccount 1162 days ago
I’ve been enjoying writing libraries in C and being able to use them both from native applications and in web apps via WASM. I personally avoid emscripten and just implement the minimal C/JS glue and utilities myself.
1 comments

What library or such if any do you use for string.h/math.h/snprintf and such?
For snprintf I use stb sprintf [1]. For the reasonable functions from string.h (memset, memcpy, memmove), you can just use compiler builtins (__builtin_memset, etc.) as long as you enable the bulk memory extension (-mbulk-memory). I haven’t needed much of math.h for the stuff I’ve made, when I have I just called stuff on the `Math` object in javascript.

[1] https://github.com/nothings/stb/blob/master/stb_sprintf.h