commit 4b68176e2bfbb30df5a9820800a53d87ca7d0620
parent c5eea59cb17fc33ed9857467c0f62560ee437a0e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sat, 9 May 2015 20:02:55 +0200
Add #error to cc1
Diffstat:
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/cc1/cpp.c b/cc1/cpp.c
@@ -57,6 +57,13 @@ pragma(char *s)
return s;
}
+static char *
+usererr(char *s)
+{
+ fprintf(stderr, "%s:%u:error: #error %s\n", filename(), fileline(), s);
+ exit(-1);
+}
+
char *
preprocessor(char *p)
{
@@ -65,11 +72,13 @@ preprocessor(char *p)
static char **bp, *cmds[] = {
"include",
"pragma",
+ "error",
NULL
};
static char *(*funs[])(char *) = {
include,
- pragma
+ pragma,
+ usererr
};
while (isspace(*p))