diff --git a/tccpp.c b/tccpp.c index 4d9430d..b26dbee 100644 --- a/tccpp.c +++ b/tccpp.c @@ -1478,6 +1478,8 @@ static void pragma_parse(TCCState *s1) } next(); skip(')'); + } else if (tok == TOK_once) { + add_cached_include(s1, file->filename, TOK_once); } else { tcc_warning("unknown #pragma %s", get_tok_str(tok, &tokc)); } @@ -1618,7 +1620,7 @@ ST_FUNC void preprocess(int is_bof) } e = search_cached_include(s1, buf1); - if (e && define_find(e->ifndef_macro)) { + if (e && (define_find(e->ifndef_macro) || e->ifndef_macro == TOK_once)) { /* no need to parse the include because the 'ifndef macro' is defined */ #ifdef INC_DEBUG diff --git a/tcctok.h b/tcctok.h index ace81dc..3de3ae2 100644 --- a/tcctok.h +++ b/tcctok.h @@ -157,6 +157,7 @@ DEF(TOK_lib, "lib") DEF(TOK_push_macro, "push_macro") DEF(TOK_pop_macro, "pop_macro") + DEF(TOK_once, "once") /* builtin functions or variables */ #ifndef TCC_ARM_EABI