c ++编译失败并出现错误:命名空间'std'中没有名为'snprintf'的成员

时间:2012-04-07 12:17:00

标签: c++ xcode stl

几分钟前它可以成功编译。 在我尝试通过按“配置文件”按钮构建项目之后出现了问题。之后,我的项目不能再编译了。

错误消息是:

In file included from /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/latte_prefix.h:24:
In file included from /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/iostream:44:
In file included from /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/ostream:44:
In file included from /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/ios:42:
In file included from /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/iosfwd:44:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1/bits/c++locale.h:48:
In file included from /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/cstdio:52:
In file included from /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/tr1/stdio.h:37:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1/tr1/cstdio:46:14: error: no member named 'snprintf' in namespace 'std'
  using std::snprintf;
        ~~~~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1/tr1/cstdio:47:14: error: no member named 'vsnprintf' in namespace 'std'
  using std::vsnprintf;
        ~~~~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1/tr1/cstdio:49:14: error: no member named 'vfscanf' in namespace 'std'
  using std::vfscanf;
        ~~~~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1/tr1/cstdio:50:14: error: no member named 'vscanf' in namespace 'std'
  using std::vscanf;
        ~~~~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1/tr1/cstdio:51:14: error: no member named 'vsscanf' in namespace 'std'
  using std::vsscanf;
        ~~~~~^
In file included from /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/latte_prefix.h:24:
In file included from /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/iostream:44:
In file included from /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/ostream:44:
In file included from /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/ios:42:
In file included from /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/iosfwd:44:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1/bits/c++locale.h:48:
/Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/cstdio:99:11: error: no member named 'FILE' in the global namespace
  using ::FILE;
        ~~^
/Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/cstdio:100:11: error: no member named 'fpos_t' in the global namespace
  using ::fpos_t;
        ~~^
/Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../../../../../../../../usr/include/c++/4.2.1/cstdio:102:11: error: no member named 'clearerr' in the global namespace
  using ::clearerr;
        ~~^

编译脚本是:

ProcessPCH++ /var/folders/r7/g6yvk_7s2zg0w0tndvr74qwc0000gn/C/com.apple.Xcode.501/SharedPrecompiledHeaders/latte_prefix-calwfgjtbaftrwfxqlbgygvcoqtm/latte_prefix.h.pth latte_prefix.h normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte
    setenv LANG en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++-header -arch x86_64 -fmessage-length=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-sign-compare -Wno-shorten-64-to-32 -Wno-newline-eof -Wc++11-extensions -DNET_DUMP=0 -DDEBUG=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -fasm-blocks -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.7 -g -Wno-conversion -Wno-sign-conversion -I/Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/build/latte.build/Debug/latte.build/latte.hmap -I/Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte -I/Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/../../sdk -I/Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/build/Debug/include -I/Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/build/latte.build/Debug/latte.build/DerivedSources/x86_64 -I/Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/build/latte.build/Debug/latte.build/DerivedSources -Wall -F/Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/build/Debug --serialize-diagnostics /var/folders/r7/g6yvk_7s2zg0w0tndvr74qwc0000gn/C/com.apple.Xcode.501/SharedPrecompiledHeaders/latte_prefix-calwfgjtbaftrwfxqlbgygvcoqtm/latte_prefix.h.dia -c /Users/wangyj1203/workspace/project_x/svn/src/c++/src/latte/latte_prefix.h -o /var/folders/r7/g6yvk_7s2zg0w0tndvr74qwc0000gn/C/com.apple.Xcode.501/SharedPrecompiledHeaders/latte_prefix-calwfgjtbaftrwfxqlbgygvcoqtm/latte_prefix.h.pth -MMD -MT dependencies -MF /var/folders/r7/g6yvk_7s2zg0w0tndvr74qwc0000gn/C/com.apple.Xcode.501/SharedPrecompiledHeaders/latte_prefix-calwfgjtbaftrwfxqlbgygvcoqtm/latte_prefix.h.d

1 个答案:

答案 0 :(得分:3)

snprintf()来自C99标准。您不应该使用名称空间std。只需使用全局命名空间。

不要忘记包含stdio.h