diff options
Diffstat (limited to 'libcpp/directives.c')
| -rw-r--r-- | libcpp/directives.c | 20 |
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) |

