SAL at Microsoft

Kagamin spam at here.lot
Mon Feb 28 05:46:06 PST 2011


bearophile Wrote:

> In most cases you don't want to print a format string, so if you write:
> 
> @format_string string f = "%d";
> writeln(f, 10);
> 
> The compiler is probably able to show a warning, that says that you are using a format string as first argument of a printing function that doesn't use a format string :-) And this warning is enough to catch that bug.
> 

In most cases you just throw format string wherever it goes without annotations :)
What you want can be dealt with a usual struct wrapper aka strong typedef.

To catch bug with argument types you need to pass string literal directly to the format parameter.


More information about the Digitalmars-d mailing list