From cb8d46b1abb7885c794eeec0fc8e4a3b359ee5e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 10 Feb 2026 11:35:41 +0000 Subject: [PATCH] fix tcc --- ast.c | 4 ++-- common.h | 12 +++++++++++- main.c | 2 ++ parser.c | 3 ++- tokenizer.c | 3 ++- zig0.c | 2 ++ 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ast.c b/ast.c index 22079108bd..75afe85fa5 100644 --- a/ast.c +++ b/ast.c @@ -1,10 +1,10 @@ +#include "common.h" + #include -#include #include #include #include "ast.h" -#include "common.h" #include "parser.h" #define N 1024 diff --git a/common.h b/common.h index c3b4b0ce96..036a3eee9a 100644 --- a/common.h +++ b/common.h @@ -1,7 +1,17 @@ -// common.h +// common.h — must be included before any system headers. #ifndef _ZIG0_COMMON_H__ #define _ZIG0_COMMON_H__ +// tcc doesn't define __GNUC__, causing glibc to #define __attribute__ to +// nothing. +#if defined(__TINYC__) && !defined(__GNUC__) +#define __GNUC__ 2 +#define __GNUC_MINOR__ 0 +#undef __REDIRECT +#undef __REDIRECT_NTH +#undef __REDIRECT_NTHNL +#endif + #include #include diff --git a/main.c b/main.c index e15443cb32..16909955eb 100644 --- a/main.c +++ b/main.c @@ -1,3 +1,5 @@ +#include "common.h" + #include #include #include diff --git a/parser.c b/parser.c index 0e0ec9d6a6..f0c6a50c1b 100644 --- a/parser.c +++ b/parser.c @@ -1,10 +1,11 @@ +#include "common.h" + #include #include #include #include #include "ast.h" -#include "common.h" #include "parser.h" const AstNodeIndex null_node = 0; diff --git a/tokenizer.c b/tokenizer.c index 24bf4681ab..3607118524 100644 --- a/tokenizer.c +++ b/tokenizer.c @@ -1,5 +1,6 @@ +#include "common.h" + #include -#include #include #include diff --git a/zig0.c b/zig0.c index 40e9480c27..528305a9bb 100644 --- a/zig0.c +++ b/zig0.c @@ -1,3 +1,5 @@ +#include "common.h" + #include #include #include