In this case, you don't have to look far to see that you can't use the return value of printf.
According to my manpage, printf returns 0 on success, 1 on failure. No mention of the number of characters written. This is different with sprintf/snprintf (see e.g http://www.opengroup.org/onlinepubs/000095399/functions/snprintf.html), but IIRC a number of platforms don't implement those according to the standard anyway. I suppose that the most portable way to achieve what you want here is to write to a temporary string, then compare the lengths of the temporary strings... Or just add a call to _set_printf_count_output in the relevant place, since AFAIK %n is still a standard-mandated printf format flag. [Shameless *nix zealot plug] Or use a Real Operating System ;-) // Simon On 6/6/07, Olivier Hainque <[EMAIL PROTECTED]> wrote:
Hello, genmodes.c uses the %n capabilities of printf to compute the width of pieces it outputs. This causes troubles on Windows Vista, because ... << Because of security reasons, support for the %n format specifier is disabled by default in printf and all its variants. ... the default behavior is to invoke the invalid parameter handler ... >> [http://msdn2.microsoft.com/en-us/library/ms175782%28VS.80%29.aspx] It seems to me that we could replace the uses of %n by uses of printf return values. I'm not clear whether this would be considered portable enough, however. Opinions ? Thanks in advance, Olivier