Is it possibly to write a gcc macro that destringifies a string literal argument? I know the opposite is possible with #
. Can it be reversed?
For example, __func__
evaluates to the name of the current function in the form of a string literal. Can I remove the double quotation marks around it?
__FILE__ This macro expands to the name of the current input file, in the form of a C string constant. This is the path by which the preprocessor opened the file, not the short name specified in ' #include ' or as the input file name argument. For example, "/usr/local/include/myheader.
Removing comments : It removes all the comments. A comment is written only for the humans to understand the code. So, it is obvious that they are of no use to a machine. So, preprocessor removes all of them as they are not required in the execution and won't be executed as well.
The -E option causes gcc to run the preprocessor, display the expanded output, and then exit without compiling the resulting source code.
No, it is not possible to convert "foo"
to foo
using the standard C/C++ preprocessor. If you absolutely need this, you would need to create an external preprocessing program, similar to what Qt does with its moc
tool.
Not completely on-topic, but the D language has exactly this functionality - it's called mixins. You can execute arbitrary string processing code at compile time and "paste" the result into your source file with the mixin
keyword.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With