Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ compile fail with error: no member named 'snprintf' in namespace 'std'

Tags:

c++

xcode

stl

It can be compiled successfully a few minutes ago. And the issue cames after my trying to build the project by pressing the "Profile" button. After that, my project cannot be compiled any more.

The error message is:

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;
        ~~^

the compile script is:

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
like image 998
Jason Cheng Avatar asked Apr 07 '12 12:04

Jason Cheng


1 Answers

snprintf() comes from the C99 standard. You should not use namespace std for it. Just use the global namespace.

Don't forget to include stdio.h

like image 146
Sergey K. Avatar answered Oct 15 '22 20:10

Sergey K.