aboutsummaryrefslogtreecommitdiff
path: root/libcpp/directives.c
diff options
context:
space:
mode:
authordfranke <dfranke@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-22 18:04:32 +0000
committerdfranke <dfranke@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-22 18:04:32 +0000
commit85e51d592d9dd5eca0c93d25fb71bb85d9d6ccbf (patch)
treeada84af9f669b80ebfb7743802f328e8b26b93e3 /libcpp/directives.c
parentbf8883372dbb667cac373aa9692bd0a60ba5dfdf (diff)
2008-04-22 Daniel Franke <franke.daniel@gmail.com>
* include/cpplib.h (cpp_define_formatted): New. * directives.c (cpp_define_formatted): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134564 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/directives.c')
-rw-r--r--libcpp/directives.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c
index 3478cd5047a..bac08ad2f46 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -2123,6 +2123,26 @@ cpp_define (cpp_reader *pfile, const char *str)
run_directive (pfile, T_DEFINE, buf, count);
}
+
+/* Use to build macros to be run through cpp_define() as
+ described above.
+ Example: cpp_define_formatted (pfile, "MACRO=%d", value); */
+
+void
+cpp_define_formatted (cpp_reader *pfile, const char *fmt, ...)
+{
+ char *ptr = NULL;
+
+ va_list ap;
+ va_start (ap, fmt);
+ vasprintf (&ptr, fmt, ap);
+ va_end (ap);
+
+ cpp_define (pfile, ptr);
+ free (ptr);
+}
+
+
/* Slight variant of the above for use by initialize_builtins. */
void
_cpp_define_builtin (cpp_reader *pfile, const char *str)