arena
arena copied to clipboard
Added format attribute to arena_sprintf
I noticed that we do not get compiler warnings when we try to compile something like
#include <stdio.h>
#define ARENA_IMPLEMENTATION
#include "arena.h"
int main() {
Arena a = {0};
char *test1 = arena_sprintf(&a, "foo", 3, "bar");
char *test2 = arena_sprintf(&a, "foo %d %s", 3);
char *test3 = arena_sprintf(&a, "foo %d", "baz");
printf("%s\n", test1);
printf("%s\n", test2);
printf("%s\n", test3);
}
At least for gcc and clang this is possible to enable by using an attribute. So I copied the macro CHECK_PRINTF_FMT from this old linear algebra project of yours: https://github.com/tsoding/la/blob/master/lag.c
Now we get some warnings for the above code.