2011-04-06 51 views
0

我似乎能够编译代码调用wsprintfMinGWgcc,如果我有这包括(按照这个顺序):什么标题必须包含使用wsprintf使用MinGW

#include <stdarg.h> 
#include <wingdi.h> 
#include <winuser.h> 

但我觉得可能有一些“更干净”的方式来做到这一点。也许只有一个头文件。我通过搜索头文件中缺失的符号,然后逐个包含头文件来到此列表。

回答

0

你的意思是标准功能swprintf?在这种情况下,您应该包含wchar.h

+0

没有,'wsprintf'。我确实尝试过'wchar.h',但这似乎不起作用。 – 2011-04-06 11:16:27

1

你的意思是swprintf()

swprintf()在C99标准中描述。你需要<wchar.h>

如果wsprintfswprintf的功能相同,则可以考虑使用标准功能。

 
     7.24.2.3 The swprintf function 

     Synopsis 

     [#1] 

       #include <wchar.h> 
       int swprintf(wchar_t * restrict s, 
         size_t n, 
         const wchar_t * restrict format, ...); 

     Description 

     [#2] The swprintf function is equivalent to fwprintf, except 
     that the argument s specifies an array of wide characters 
     into which the generated output is to be written, rather 
     than written to a stream. No more than n wide characters 
     are written, including a terminating null wide character, 
     which is always added (unless n is zero). 
相关问题