There's got to be a way to do this...
I have a header file, version.h with one line...
#define VERSION 9
and a few files use the defined value of VERSION as an integer. That's fine.
Without changing the way VERSION is defined, I need to build an initialized "what" string that contains that value, so I need something like this...
char *whatversion = "@(#)VERSION: " VERSION;
obviously this doesn't compile, so somehow I need to get a string of the preprocessed value of VERSION essentially giving this...
char *whatversion = "@(#)VERSION: " "9";
Any ideas? Is this possible?
It is not a datatype, it is a token. A blob of text.
K & R
talk about concatenating values:
The preprocessor operator ## provides a way to concatenate actual arguments
during macro expansion. If a parameter in the replacement text is adjacent
to a ##, the parameter is replaced by the actual argument, the ## and
surrounding white space are removed, and the result is re-scanned. For example,
the macro paste concatenates its two arguments:
#define paste(front, back) front ## back
so paste(name, 1) creates the token name1.
-- try that. #define the string before you get to char *version=
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