shithub: scc

Download patch

ref: 4b68176e2bfbb30df5a9820800a53d87ca7d0620
parent: c5eea59cb17fc33ed9857467c0f62560ee437a0e
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat May 9 16:02:55 EDT 2015

Add #error to cc1

--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -57,6 +57,13 @@
 	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 @@
 	static char **bp, *cmds[] = {
 		"include",
 		"pragma",
+		"error",
 		NULL
 	};
 	static char *(*funs[])(char *) = {
 		include,
-		pragma
+		pragma,
+		usererr
 	};
 
 	while (isspace(*p))