c - Inlining a script using macro -


i working script engine, , i'd able or similar:

const char* script = some_macro(     function foo() {         print "bar";     }     foo(); ) os* engine = os::create(); engine->eval(script); 

what way achieve this?

i know multiline macros, i'd need \ @ end of line, , if possible, i'd avoid using bunch of quoted strings, since script might quoted strings too, , id preserve line numbers.

is there way so?

you don't need macros. can use raw string literals.

const char* script = r"script_delimiter(     function foo() {         print "bar";     }     foo(); )script_delimiter"; 

you can replace script_delimiter delimiter want, 16 characters, no parentheses, backslashes or spaces, , sequence )your_delimiter" can not appear in string (because used terminate it).


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -