Menu

#78 wprintf format check attribute

pending
nobody
5
2015-11-21
2015-11-18
White-Tiger
No

__attribute__ ((format (wprintf, 1, 2)))
doesn't work for wprintf as a wprintf format is unknown and the printf format doesn't accept wchar_t strings..

So all wprintf like functions are missing the feature to have their arguments checked against the specified format string as done with printf like functions.
There was a patch to GCC in 2001 (14 years ago) which tried to accomplish this, but doesn't seem to be adapted "yet"
https://gcc.gnu.org/ml/gcc-patches/2001-12/msg01579.html

Since MinGW already provides gnu_printf and ms_printf format attributes, I don't see why MinGW shouldn't also implement their own gnu_wprintf and ms_wprintf format attributes as for the target being Windows and wchar_t being quite common here. (or just allow gnu_printf to parse wchar_t format strings since it currently complains that it isn't a string^^)

It really sucks to have no syntax check for wide char format functions (including wsprintfW which shouldn't be confused with swprintf).

Maybe you guys could even talk to the GCC people so they might finally implement it there.. (as swprintf also exists there, though it is likely more important to Windows)

Discussion

  • Kai Tietz

    Kai Tietz - 2015-11-21

    Hi,

    this is clearly a compiler-feature. Of course it would be of interest to support it in our headers, if there is a by us supported compiler, which supports this feature.

    For Gcc it might get hard to push such a feature upstream as there language-maintainers people tend to see either just on the things defined in standards, or are important on some *nix targets. Nevertheless if you want to work on such a feature upstream (and have made already paperwork with FSF for it), I will support you happily there in the role of Windows-target maintaner on gcc.

     
  • Kai Tietz

    Kai Tietz - 2015-11-21
    • status: open --> pending
     
  • White-Tiger

    White-Tiger - 2015-11-21

    I doubt that ms_printf comes directly from GCC... so what's the difference to a wide char version?

     

    Last edit: White-Tiger 2015-11-21
  • Kai Tietz

    Kai Tietz - 2015-11-21

    well, so you are mistaken. The difference is that handling of printf-formatters don't support for now wide-character variant.

     

Log in to post a comment.