Hi, thanks for the reply.
On 4/8/12 6:25 AM, Joseph S. Myers wrote:
Character pairs like this don't seem very extensible, in that you are
providing meanings for any even-length string, rather than (for example)
only a limited subset of strings leaving room for meanings to be assigned
later to other strings.
Future extensions could use identifiers rather than strings, or other
syntax, but understood.
They also have the obvious problem of not covering application-specific
types as arguments, only types that have corresponding standard formats.
In principle we want extensibility of format checking, and want it to be
as flexible as the built-in checking is regarding the peculiarities of
different formats - but we also don't want to export implementation
details of format checking to users' source code, and the two points seem
rather to contradict each others. So my recent inclination has been that
we should make it possible for plugins to add new format checking types
(but the details of the relevant interfaces would be unstable, so such
plugins might need to change for each GCC version). That means a function
for a plugin to register a new format type - and probably a callback
called when that format type is used for a function declaration that can
look for a typedef name in the same way that the existing GCC-internal
formats are handled.
The plugin architecture would work great for format strings that are
very different from printf/scanf, but seems heavyweight for format
strings that are close to printf/scanf.
Would a better syntax for "printf/scanf + extensions" format strings be
worth accepting independent of plugins?
__attribute__(printf, 1, 1, '<' ('%'), ';' ('0'))
==> treat '<' like '%' and ';' like '0'
__attribute__(printf, 1, 1, '<' (), 'F' (expr *))
==> '<' takes 0 arguments, 'F' takes an expr * argument in the list