'powf' is not a member of 'std'

北慕城南 提交于 2019-12-05 07:50:48

Up until C++11, powf was just a Microsoft-ism. It did not appear in the ISO standard at all so is unlikely to be in XCode unless they were to adapt Microsoft's bizarre practices, something I would think unlikely.

pow, on the other hand, has been part of the C++ library for longer by virtue of the fact that it's in earlier iterations of the C library that is incorporated into C++ pre-11. Use that instead.

Since C++11, powf does appear in the ISO standard and is part of the std namespace.

Nevertheless, there are non-compliant implementations e.g., gcc libstdc++. More resources in this excerpt taken from a discussion in cppreference talk page:

Answers posted above were correct before C++11, since C++98/03 hadn't referred C99 library yet. According to the current standard, powf is declared in namespace std when is included (explicitly mentioned since C++17, implicitly mentioned in C++11/14, see also N4659, N4140 and N3337). For std::powf, gcc libstdc++ is not compliant while clang libc++ is. --Fruderica (talk) 03:49, 19 February 2019 (PST)

See also this, more recent, SO answer: https://stackoverflow.com/a/54735351 --Cubbi (talk) 08:10, 19 February 2019 (PST)

Use just pow - powf isn't standard.

It is named std::pow and overloaded for float and double.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!