3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【g++】「error: 'stof' was not declared in this scope」と言われた時の対処方法

Posted at

はじめに

C++のbundleとしてXcodeで作成したときは問題がなかったプログラムがg++(gcc version:4.9.0)でコンパイルした際にerror: 'stof' was not declared in this scopeというエラーに。
これはstringに入っているstd::stofを使おうとしてて、ちゃんとincludeしていたのですが...なぜに。っと思ってGoogle先生に聞いたところ、gccのバグだとかの話が出たりしたんですけど、結局はコンパイル時にある魔法の言葉をつけるだけで解決しました。

魔法の言葉

魔法の言葉、それは

-std=c++11

です。例としては次の通りです。

g++ -std=c++11 main.cpp

魔法の言葉の意味

これはC++11の機能を使うために、明示的にオプションで指定しているもので、C++11の拡張やライブラリを使用しますよーって言ってるものです(。・∀・)ノ

もし魔法の言葉が効かない場合

g++(gcc)のバージョンが古い可能性があるのでアップデートするとできるらしいです( º言º` )

参考URL

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?