[Solved] How to pass a String without quotes to function? [closed]


Answering my own question.

void callJavaScript(std::string script) {

    std::cout << script << "\n";
}

#define callJavaScript(...) callJavaScript(#__VA_ARGS__)

Now you can call like this,

callJavaScript({
   console.log("Hello World")
})

You can compile this then it will output

{console.log("Hello World")}

If anyone has a better way with templates, please do tell.

solved How to pass a String without quotes to function? [closed]