aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/directives.c23
-rw-r--r--libcpp/include/cpplib.h4
2 files changed, 27 insertions, 0 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c
index 4295a67..c4ecb96 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -2412,6 +2412,15 @@ cpp_define (cpp_reader *pfile, const char *str)
run_directive (pfile, T_DEFINE, buf, count);
}
+/* Like cpp_define, but does not warn about unused macro. */
+void
+cpp_define_unused (cpp_reader *pfile, const char *str)
+{
+ unsigned char warn_unused_macros = CPP_OPTION (pfile, warn_unused_macros);
+ CPP_OPTION (pfile, warn_unused_macros) = 0;
+ cpp_define (pfile, str);
+ CPP_OPTION (pfile, warn_unused_macros) = warn_unused_macros;
+}
/* Use to build macros to be run through cpp_define() as
described above.
@@ -2431,6 +2440,20 @@ cpp_define_formatted (cpp_reader *pfile, const char *fmt, ...)
free (ptr);
}
+/* Like cpp_define_formatted, but does not warn about unused macro. */
+void
+cpp_define_formatted_unused (cpp_reader *pfile, const char *fmt, ...)
+{
+ char *ptr;
+
+ va_list ap;
+ va_start (ap, fmt);
+ ptr = xvasprintf (fmt, ap);
+ va_end (ap);
+
+ cpp_define_unused (pfile, ptr);
+ free (ptr);
+}
/* Slight variant of the above for use by initialize_builtins. */
void
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 8900e77..ce00952 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -1076,8 +1076,12 @@ extern cppchar_t cpp_host_to_exec_charset (cpp_reader *, cppchar_t);
/* Used to register macros and assertions, perhaps from the command line.
The text is the same as the command line argument. */
extern void cpp_define (cpp_reader *, const char *);
+extern void cpp_define_unused (cpp_reader *, const char *);
extern void cpp_define_formatted (cpp_reader *pfile,
const char *fmt, ...) ATTRIBUTE_PRINTF_2;
+extern void cpp_define_formatted_unused (cpp_reader *pfile,
+ const char *fmt,
+ ...) ATTRIBUTE_PRINTF_2;
extern void cpp_assert (cpp_reader *, const char *);
extern void cpp_undef (cpp_reader *, const char *);
extern void cpp_unassert (cpp_reader *, const char *);