windows swprintf 和 vswprintf 未声明?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3445312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:00:41  来源:igfitidea点击:

swprintf and vswprintf not declared?

c++windowsmingwbotan

提问by Jake Petroules

I am trying to compile Botan on Windows with MinGW, and am receiving the following error during compilation:

我正在尝试使用 MinGW 在 Windows 上编译 Botan,并且在编译过程中收到以下错误:

c:\qt10.04\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159: error:
'::swprintf' has not been declared
c:\qt10.04\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:166: error:
'::vswprintf' has not been declared

Why are swprintf and vswprintf not declared, and how can I fix this?

为什么没有声明 swprintf 和 vswprintf,我该如何解决这个问题?

回答by carlsborg

Try putting in

尝试放入

#undef __STRICT_ANSI__ 

before including stdio.h

在包含 stdio.h 之前

回答by Sebastian

had the same problem compiling Grantlee using MinGW (Qt 2010.05).

使用 MinGW (Qt 2010.05) 编译 Grantlee 时遇到了同样的问题。

How I got it to compile:

我是如何编译的:

  • find file cwchar (C:\Qt\2010.05\mingw\lib\gcc\mingw32\4.4.0\include\c++\cwchar)
  • comment the following lines out (around line 160)

    using ::swprintf;

    using ::vswprintf;

  • 找到文件 cwchar (C:\Qt\2010.05\mingw\lib\gcc\mingw32\4.4.0\include\c++\cwchar)
  • 注释掉以下几行(第 160 行左右)

    使用::swprintf;

    使用::vswprintf;

回答by sabertooth1990

When running make ensure that -ansi flag is not set. If this flag is being used then remove it and the problem will be solved.

运行 make 时确保未设置 -ansi 标志。如果正在使用此标志,则将其删除,问题将得到解决。