aboutsummaryrefslogtreecommitdiff
path: root/libcpp/directives.c
diff options
context:
space:
mode:
authorDaniel Franke <franke.daniel@gmail.com>2008-04-22 14:04:32 -0400
committerDaniel Franke <dfranke@gcc.gnu.org>2008-04-22 14:04:32 -0400
commit28f68625537daa396681d2b5bc5f5ada52d5853d (patch)
treeada84af9f669b80ebfb7743802f328e8b26b93e3 /libcpp/directives.c
parent6ca1c37cdb07ca6f8e6e608dae53ea89a1c5b3e8 (diff)
downloadgcc-28f68625537daa396681d2b5bc5f5ada52d5853d.zip
gcc-28f68625537daa396681d2b5bc5f5ada52d5853d.tar.gz
gcc-28f68625537daa396681d2b5bc5f5ada52d5853d.tar.bz2
cpplib.h (cpp_define_formatted): New.
2008-04-22 Daniel Franke <franke.daniel@gmail.com> * include/cpplib.h (cpp_define_formatted): New. * directives.c (cpp_define_formatted): New. From-SVN: r134564
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 3478cd5..bac08ad 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)