Skip to content

Conversation

@Pecora0
Copy link
Contributor

@Pecora0 Pecora0 commented May 28, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant