Re:Crow – C++ Microframework for Web, inspired by Python Flask
by unwind on Tuesday July 08, 2014 @02:28AM
(#8003256)
Not sure if you're being ironic, but you're describing e.g. GCC's "format" function attribute (https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#...), it makes the compiler verify the arguments for printf() and other format-string functions.
It's not new, it has been in GCC for quite a number of years (not sure how to check this quickly).
UPDATE: I found a list (https://ohse.de/uwe/articles/gcc-attributes.html#func-format) that says format was added in GCC 2.3-3.4 (whatever the range means). GCC 3.4.0 was released on April 18 2004. Now I'm sad I didn't say "ten years" above, as my original hunch was. :)
Re:Crow – C++ Microframework for Web, inspired by Python Flask
by nly on Tuesday July 08, 2014 @09:03AM
(#8004311)
Specific to printf and scanf format codes though, not under the control of the programmer.
Re:Crow – C++ Microframework for Web, inspired by Python Flask
by nly on Tuesday July 08, 2014 @09:04AM
(#8004317)
boost::format does away with format codes altogether... you just use '%' place holders. Using constexpr string literal evaluation would be useful for counting them at compile time though.
Maybe this technique could be applied in printf or other C++ APIs using format string.