diff options
Diffstat (limited to 'src/mcpp-diagnostic.c')
| -rw-r--r-- | src/mcpp-diagnostic.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mcpp-diagnostic.c b/src/mcpp-diagnostic.c new file mode 100644 index 0000000..76e0c25 --- /dev/null +++ b/src/mcpp-diagnostic.c @@ -0,0 +1,28 @@ +#include <defs.h> +#include <stdarg.h> + +int +mcpp_diagnostic_warning( const mcpp_options *options, + const char *filename, + unsigned line_number, + const char *format, ... ) +{ + va_list ap; + int as_error; + + if( options != NULL && options->inhibit_warnings ) + return( 0 ); + + as_error = options != NULL && options->warnings_are_errors; + + fprintf( stderr, "%s:%u: %s: ", + filename != NULL ? filename : "<input>", line_number, + as_error ? "error" : "warning" ); + + va_start( ap, format ); + vfprintf( stderr, format, ap ); + va_end( ap ); + fputc( '\n', stderr ); + + return( as_error ? -1 : 0 ); +} |
