在 VS2015 上使用 -std=c++11 [英] Using -std=c++11 on VS2015

查看:279
本文介绍了在 VS2015 上使用 -std=c++11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual Studio 2015 中为 Android 创建了一个共享对象.

I have created a shared object for Android in Visual Studio 2015.

到目前为止它工作正常,但是对于 wstring 的 pop_back() 不起作用:

It works fine so far, but pop_back() for a wstring does not work:

        wstring element = "JustATest!";
        if (element.back() == L'!')
        {
            element.pop_back();
        }

VS2015 告诉我:在‘std::basic_string<wchar_t>’中没有名为‘pop_back’的成员".

VS2015 tells me: "no member named 'pop_back' in 'std::basic_string<wchar_t>'".

谁能告诉我如何摆脱这个错误?我不知道为什么这不起作用.是不是因为某些原因 VS2015 没有在这里使用 C++11 ?

Can anybody tell me how to get rid of this error? I have no idea why this should not work. Is that because for some reason VS2015 does not use C++11 here?

感谢您的帮助!

另一个错误:

当我尝试使用 _wtoi 时,VS 告诉我:使用未声明的标识符 '_wtoi'.非常非常奇怪.

When I try to use _wtoi, VS tells me: "use of undeclared identifier '_wtoi'. Very very strange.

推荐答案

您需要开启 STL 支持.使用 Configuration Properties -> General -> Use of STL 打开 STL.不错的选择是 LLVM libc++ 静态库(功能更少,与 CLANG 更兼容)和 GNU STL 静态库(更多功能,我有一个问题需要我将 CLANG 优化器转换为 -Oz 以防止段错误).

You need to turn on STL support. Turn on STL with Configuration Properties -> General -> Use of STL. Good options are LLVM libc++ static library (fewer features, more compatible with CLANG) and GNU STL static library (more features, I had an issue that required me to turn the CLANG optimizer to -Oz to prevent a segfault).

这篇关于在 VS2015 上使用 -std=c++11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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