#168·chibicc

bug with __has_include and valgrind header

Author: lucas-miorCreated Mar 27, 2026Updated Mar 30, 2026

The following program does not compile:

c
// chibicc

void function(void) {
    // this function is here just to show that the problem is not on line 1
}

#if defined(__has_include) && __has_include(<valgrind/valgrind.h>)
#include <valgrind/valgrind.h>
#endif

#include "stdio.h"

int main(void) {
    printf("This program should compile.\n");
    return 0;
}

The error message is:

main.c:1: 0
          ^ not a function

Also note that the error message says line 1, independent of where the valgrind macro directive is.