gprintの4.8.2でsnprintfを使用し、-std = C++ 11で成功しないコンパイルコードを試しています。 g ++がsnprintfを認識しないのはなぜですか? snprintfとC++ 11を使っているのにこれを克服できますか?g ++でのsnprintf()の使用方法-std = C++ 11バージョン4.8.2
私は次のように得た:
make all Building file: ../src/cppHWtest.cpp Invoking: Cygwin C++
Compiler g++ -std=c++11 -D"hash_map=unordered_map" -O0 -g3 -Wall -c
-fmessage-length=0 -MMD -MP -MF"src/cppHWtest.d" -MT"src/cppHWtest.d" -o "src/cppHWtest.o" "../src/cppHWtest.cpp" cygwin warning: MS-DOS style path detected: C:\Users\poudyal\workspace\cppHWtest\Debug
Preferred POSIX equivalent is:
/cygdrive/c/Users/poudyal/workspace/cppHWtest/Debug CYGWIN
environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames ../src/cppHWtest.cpp: In function 'int main()':
../src/cppHWtest.cpp:20:35: error: 'snprintf' was not declared in this
scope snprintf(buff, 10, "%s", "Hell O");
^make: *** [src/cppHWtest.o] Error 1 src/subdir.mk:18: recipe for target 'src/cppHWtest.o' failed
**** Build Finished ****
[このcygwinメーリングリストのアーカイブスレッド](http://cygwin.com/ml/cygwin/2012-04/msg00140.html)は 'snprintf'を' -std = C++ 0x'。回避策として、 '-std = gnu ++ 0x'を代わりに使用することをお勧めしました。ちょうどそのために、 '-std = gnu ++ 11'を試してみて、何が起こるか見てみましょう。 – Casey
これはうまくいった!私も#includeを持っていた –
vjktm
今、ベクトルに同じ問題があることがわかりました。ベクトル<>は-std = C++で問題ありません。11 –
vjktm