From 3023aa2c13ae739bbb90cfa954d0f1fcbdc49be7 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Fri, 10 Jun 2011 11:52:55 +0200 Subject: [PATCH] Allow commandline defines with string values --- macro/MacroDriver.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/macro/MacroDriver.cc b/macro/MacroDriver.cc index f2f2477e..21adc04e 100644 --- a/macro/MacroDriver.cc +++ b/macro/MacroDriver.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include "MacroDriver.hh" @@ -55,7 +56,15 @@ MacroDriver::parse(const string &f, ostream &out, bool debug, bool no_line_macro stringstream file_with_endl; for (map::iterator it=defines.begin(); it!=defines.end(); it++) - file_with_endl << "@#define " << it->first << " = " << it->second << endl; + try + { + boost::lexical_cast(it->second); + file_with_endl << "@#define " << it->first << " = " << it->second << endl; + } + catch(boost::bad_lexical_cast &) + { + file_with_endl << "@#define " << it->first << " = \"" << it->second << "\"" << endl; + } file_with_endl << in.rdbuf() << endl; lexer = new MacroFlex(&file_with_endl, &out, no_line_macro);