错误 strlen 不是 std 的成员,仅在 Linux 上而不是在 Solaris 上

error strlen not a member of std only on linux not on solaris

本文关键字:Solaris Linux 仅在 不是 strlen std 成员 错误      更新时间:2023-10-16

下面的代码使用Sun Studio在Solaris上编译,但在使用gcc的Linux上,它说strlen不是std的成员。

inline std::string pathname(char const *p)
{
    std::string pname;
    std::transform(p, p+std::strlen(p), std::back_inserter(pname), platform::switch_slash);
    return pname;
}

谢谢

您需要包含cstring标头才能获得std::strlen

#include <cstring>