[cfe-dev] Generating printf format specifiers
davekeck at gmail.com
Fri Jan 22 10:35:40 PST 2010
As an C/Obj-C developer, I've often thought that it would be useful to be
able to do this:
NSString *username = NSUserName();
uid_t userID = 5;
NSLog(@"Hello, " __nsfmt__(username) @"! This is your user id: "
__nsfmt__(userID), username, userID);
I imagine __nsfmt__ would work similarly to __typeof__, but rather than
substituting the type, the compiler would substitute the most natural printf
format specifier for the given type. There would also be a standard-C
__fmt__ that would generate constant C-strings rather than constant
NSStrings. Is there any reason this doesn't already exist? (Or perhaps I've
overlooked it if it does?)
Not having any experience with compiler implementation, I was hoping someone
could give me a few pointers before I try implementing such a feature?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev