I am trying to use DRY methodologies on an arbitrary collection of mixed-case words such that the text MixedCase could produce both:
- The compile-time string
"MixedCase" - The compile-time variable
const int MIXEDCASE_ID
I am using gcc, and gcc extensions would be acceptable.
Is it possible for C++ to convert test in the code to uppercase? E.g., such that
CONVERT(abc)
would produce the symbol ABC? If not, is there a solution beyond typing every sample twice in the code?
Edit: Consider that there is no restriction on the input format. Mixed or "Mixed" or 'M', 'i', 'x', 'e', 'd' or 0x4d 0x69 0x78 0x65 0x64 (yuck?)…
To do this you would need to write a build tool that preprocessed (actually prepreprocessed) your source files to make this conversion. There is no built-in feature in gcc that can do this at compile time.