Remove String Quotations Using The Preprocessor

Hi,

I'm trying to use a #define function directive to remove string quotations. Kind of like the opposite of stringizing.

For example, if there was an operator to do this which I am representing as ~ (I know there isn't but if there was). I want it to be like:

1
2
#define macr(name) ~name
text macr("name") othertext

This would then turn it into:

text name othertext

Note I am not doing this to try and get a variable value, I am running a parser upon the outputted code afterwards. I know I could use the parser itself to remove the string quotations but I want to know if there is any possible way of doing this using the preprocessor?

Thanks for any help.
Last edited on
Remove all qutation:
#define "
I don't wish to remove all the quotations, just those put in the macro function.
Last edited on
If you only wanted to add it...
...
...
Try this:
1
2
3
4
5
#define macro("
#define ")orcam

//usage
macro("name")orcam

Why won't you just write name without quotes?
Why won't you just write name without quotes?

I don't have any control over the input format.

^ That's a great idea though. But I don't know how you define braces? If you try #define macro(" it errors that it wants a closing brace as macros use the braces for the function notation.
Last edited on
I don't have any control over the input format.

You do know that preprocessor works before compilation and before any input can be made, right?

Give me an example, how do you want ot use this macro.
If the input is from a file, consider piping it through something that can do the replacement for you like sed, perl, etc..
Doesn't seem like a good idea to me, but I don't have much of an idea. I would say do it in the parser to keep the original file in it's original state.
You do understand that you should force those who send you an input file to use your macro, and if you can do that you can just tell them to not use quotes.
Topic archived. No new replies allowed.