From 2af8507661c29f11c1c024f89b067c00de016824 Mon Sep 17 00:00:00 2001 From: Jeremiah Orians Date: Thu, 15 Sep 2022 20:19:57 -0400 Subject: [PATCH] Add support for #warning --- cc_macro.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cc_macro.c b/cc_macro.c index e0a988c..a62b8b2 100644 --- a/cc_macro.c +++ b/cc_macro.c @@ -1,5 +1,6 @@ /* Copyright (C) 2021 Sanne Wouda * Copyright (C) 2021 Andrius Štikonas + * Copyright (C) 2022 Jan (janneke) Nieuwenhuizen * This file is part of M2-Planet. * * M2-Planet is free software: you can redistribute it and/or modify @@ -598,7 +599,7 @@ void handle_undef() eat_current_token(); } -void handle_error() +void handle_error(int warning_p) { /* don't use #error statements from non-included blocks */ int conditional_error = TRUE; @@ -614,7 +615,8 @@ void handle_error() if(conditional_error) { line_error_token(macro_token); - fputs(" error: #error ", stderr); + if(warning_p) fputs(" warning: #warning ", stderr); + else fputs(" error: #error ", stderr); while (TRUE) { if ('\n' == macro_token->s[0]) break; @@ -622,7 +624,7 @@ void handle_error() macro_token = macro_token->next; } fputs("\n", stderr); - exit(EXIT_FAILURE); + if(!warning_p) exit(EXIT_FAILURE); } while (TRUE) { @@ -753,7 +755,11 @@ void macro_directive() } else if(match("#error", macro_token->s)) { - handle_error(); + handle_error(FALSE); + } + else if(match("#warning", macro_token->s)) + { + handle_error(TRUE); } else if(match("#FILENAME", macro_token->s)) {