'powf' 不是 'std' 的成员 [英] 'powf' is not a member of 'std'

查看:47
本文介绍了'powf' 不是 'std' 的成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 XCode 编译库时出错:

<块引用>

'powf' 不是 'std' 的成员

包括 .

有人可以向我解释发生了什么问题吗?

解决方案

直到 C++11,powf 只是一个 微软主义.它根本没有出现在 ISO 标准中,所以不太可能出现在 XCode 中,除非他们适应微软的奇怪做法,我认为这不太可能.

另一方面,

pow 已成为 C++ 库的一部分,因为它位于 C++ 11 之前的 C 库的早期迭代中.改用那个.

从 C++11 开始,powf 确实出现在 ISO 标准中,并且是 std 命名空间的一部分.

尽管如此,还是有不合规的实现,例如 gcc libstdc++.此摘录中的更多资源取自 cppreference 讨论页:><块引用>

上面发布的答案在 C++11 之前是正确的,因为 C++98/03 还没有引用 C99 库.根据现行标准powf在包含时的命名空间 std(自 C++17 起明确提及,在 C++11/14 中隐含提及,另见 N4659N4140N3337).对于 std::powf,gcc libstdc++ 不兼容,而 clang libc++ 是.--Fruderica(谈话)2019 年 2 月 19 日 03:49(太平洋标准时间)

另见这个,最近的,SO 答案:https://stackoverflow.com/a/54735351 --Cubbi (谈话)2019 年 2 月 19 日 08:10(太平洋标准时间)

I have an error while compiling a library using XCode:

'powf' is not a member of 'std'

The <cmath> is included.

Can someone explain to me what is going wrong?

解决方案

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)

这篇关于'powf' 不是 'std' 的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆