[cfe-dev] [PATCH] Let __attribute__((format(…))) accept OFStrings

Jean-Daniel Dupas devlists at shadowlab.org
Wed Nov 27 09:43:19 PST 2013


Le 27 nov. 2013 à 18:16, David Chisnall <David.Chisnall at cl.cam.ac.uk> a écrit :

> On 27 Nov 2013, at 16:50, Jonathan Schleifer <js at webkeks.org> wrote:
> 
>> Am 27.11.2013 um 17:47 schrieb David Chisnall <David.Chisnall at cl.cam.ac.uk>:
>> 
>>> This seems the wrong way around.  You'd want to define a per-method thing, not a per-receiver thing, so we'd just want to define a new printf flavour and add things to it.  
>> 
>> Uhm, this is exactly what I meant: Add a new printf flavour, but let it accept an OFString* (or subclass) instead of a const char*. Or how exactly are we misunderstanding each other here?
> 
> You can only have one format of constant string per compilation unit, so this doesn't seem important.  The type of the constant string argument is something that is defined by the parameter type, it doesn't need to be part of the printf extension format.  

That's how I would like it to work, but currently, the printf format attribute enforce the string type.
I'd like to see this restriction relaxed, as it prevents such fun things like supporting the ObjC format using a printf implementation that support customization ( like xprintf ) and letting the compiler check the string.

If we relaxe this restriction, it would then be easier to support the OFString case as it would suppress the argument type issue.

> Instead, you want to be able to define printf-like method sets, and then attach these to methods as you currently do with the standard printf-like things.
> 
> David

-- Jean-Daniel








More information about the cfe-dev mailing list