I'm fairly new to the C preprocessor. Is it possible to change the case of an argument provided to a function-like #define
? For example, I want to write test(size)
and then involve "Size" in the resulting replacement.
views:
109answers:
2Have you? Examples please.
Mark Hurd
2010-05-06 01:43:43
+2
A:
No. The preprocessor can combine identifiers to form new ones, but it cannot modify an identifier.
James McNellis
2010-05-06 00:51:41
So, to do this--I probably won't now :(--I'd need to use something more like `test(s,S,ize)` (eww)?
andyvn22
2010-05-06 01:02:43
@andyvn: You could do it that way; note that the first parameter is unneeded. There's not much point in doing that, of course, since you have to give it the capital letter ;-).
James McNellis
2010-05-06 01:06:21
@andyvn22 - or you can do something like `test(size, Size)` - it's more redundant but has less of an eww fact (at least to me).
R Samuel Klatchko
2010-05-06 01:11:48