"#pragma once" implementation

This commit is contained in:
seyko
2015-04-21 15:46:29 +03:00
parent 0c8447db79
commit b08ce88082
2 changed files with 4 additions and 1 deletions

View File

@ -1478,6 +1478,8 @@ static void pragma_parse(TCCState *s1)
} }
next(); next();
skip(')'); skip(')');
} else if (tok == TOK_once) {
add_cached_include(s1, file->filename, TOK_once);
} else { } else {
tcc_warning("unknown #pragma %s", get_tok_str(tok, &tokc)); 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); 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' /* no need to parse the include because the 'ifndef macro'
is defined */ is defined */
#ifdef INC_DEBUG #ifdef INC_DEBUG

View File

@ -157,6 +157,7 @@
DEF(TOK_lib, "lib") DEF(TOK_lib, "lib")
DEF(TOK_push_macro, "push_macro") DEF(TOK_push_macro, "push_macro")
DEF(TOK_pop_macro, "pop_macro") DEF(TOK_pop_macro, "pop_macro")
DEF(TOK_once, "once")
/* builtin functions or variables */ /* builtin functions or variables */
#ifndef TCC_ARM_EABI #ifndef TCC_ARM_EABI