_GLIBCXX_USE_C99未定义,to_wstring不可用 [英] _GLIBCXX_USE_C99 is not defined, to_wstring not available

查看:586
本文介绍了_GLIBCXX_USE_C99未定义,to_wstring不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个非常严重的(IMO)问题.我正在Visual Studio 2015中使用本机跨平台工具.

I've run into a very serious (IMO) problem. I am using the native cross platform tools in visual studio 2015.

由于Visual Studio已下载了标准库的几种实现,所以

Since several implementations of the standard library were downloaded by visual studio

C:\ ProgramData \ Microsoft \ AndroidNDK \ android-ndk-r10e \ sources \ cxx-stl \

C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e\sources\cxx-stl\

当我开始发现未编译的stl类时,我感到很惊讶.

I was surprised when I started finding stl classes that were not compiling.

我注销了std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>不能作为 gnu-libstdc ++的怪癖.

我尝试将stl设置为其他值,以查看它们是否更好.这是在Visual Studio项目属性窗口中完成的.

I tried to set the stl to others to see if they were better. This was done in the visual studio project properties window.

没有工具集或STL的组合.std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>可用.

No combination of toolset or STL made std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> available.

我继续说,如果我必须自己实现一个功能,那就不是世界末日了."

I moved on, saying "If I have to implement that one function myself it's not the end of the world."

但是不久之后我尝试使用to_wstring.同样,即使wstring被识别,该功能也无法识别.

However shortly afterward I tried to use to_wstring. Again the function was not recognized even though wstring was.

这是一个太远的步骤,因此我检查了 gnu-libstdc ++ 是否实际上已经实现了任何东西.实际上,他们已经看到标准的21.5是Y .

This was a step too far so I checked to see if gnu-libstdc++ had in fact implemented anything at all. In fact they had, see 21.5 of the standard is Y.

我现在很困惑.我做了一些谷歌搜索,发现没有比将其设置为c ++ 11"更重要的内容了.

I was very confused now. I did some googling and found nothing more substantial than "set it to c++ 11."

除非Visual Studio在以下设置下不执行任何操作,否则我认为GCC的调用正确.

Unless Visual Studio isn't doing anything with the following setting I assume GCC is being called correctly.

最终,我在Visual Studio中打开basic_string.h,以确保该功能确实存在.

Eventually I opened up basic_string.h in visual studio to make sure that the function was actually there.

原来是3000行:

inline wstring
to_wstring(int __val)
{ return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 * sizeof(int), L"%d", __val); }

然后我通过阴影看到预处理器已将其省略.看第2847行:

Then I saw by the shading that it was being omitted by the preprocessor. Behold line 2847:

#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
     && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))

问题不是__cplusplus也不是_GLIBCXX_HAVE_BROKEN_VSWPRINTF. _GLIBCXX_USE_C99未定义.

The problem was not __cplusplus nor _GLIBCXX_HAVE_BROKEN_VSWPRINTF. _GLIBCXX_USE_C99 was not defined.

搜索此问题产生了堆栈溢出问题.

大多数评论似乎都认为该问题将通过新版GCC得以解决.例如GCC 4.4.5.但是,由于Visual Studio下载了4.9 ...我认为这不是版本问题.

Most of the comments seemed to think the problem would be fixed with a new release of GCC. For instance GCC 4.4.5. However since visual studio downloaded 4.9... I don't think this is merely a problem with versions.

我点击了链接,链接到三年的错误报告包含以下语句:

I followed the link there to a three year old bug report which contained the statement:

没有付出巨大努力就不可能在GCC中进行修复 单一目标,这将不会发生.如果给定的目标想要 要支持C ++ 11功能,则需要提供必要的C99 特征.这不是海湾合作委员会的问题.

It's not possible to fix in GCC without extraordinary effort for a single target, which is not going to happen. If a given target wants to support C++11 features then it needs to provide the necessary C99 features. This is not a GCC issue.

好吧,在Visual Studio中,我已将C标准设置为C99,因为记录C11没有任何区别.

Well, in visual studio I had set the C standard to C99, for the record C11 didn't make any difference.

我真的不确定如何从这里继续.在我看来,Visual Studio无法以某种方式不与GCC进行通信,即什么是可用的还是不可用的.但这只是一个理论.

I am really not sure how to proceed from here. It seems to me that somehow Visual Studio is not communicating to GCC what is or is not available. That is just a theory though.

我反对尝试在stl上手动更改发行版.这违反了stl的目的.同时,如果没有标准库(考虑到时间限制),我正在进行的这个项目可能是不可能的.恐怕要继续下去,以免由于缺乏C库功能而发现更多的重要功能被隐藏了.

I am opposed to trying to manually change a distribution on the stl. That defeats the purpose of a stl. At the same time this project I am undertaking may well be impossible without the standard library (given the time constraints). I am afraid to continue lest I find more critical functionality hidden due to lack of C library functions.

我如此疯狂地希望,我可以在Visual Studio中进行一些更改,可以通过某些设置或命令行替代来解决此问题.

I have this insane hope that there is something I could change in visual studio, some setting or command line override that would fix this.

P.S. 我研究了在eclipse或android studio中开发android部分的方法. NDK文档经常提到eclipse,但是android SDK包含有关不再支持ADT的可怕消息.最重要的是,我在调试本机代码时遇到了一些开箱即用的问题(但是这些问题超出了范围). android studio构建系统(gradle)似乎对自定义文件夹结构的友好程度至少不高.我们所有的资源都在TFS中,目前我无法更改.

推荐答案

这是Google的Android NDK的已知问题-除非您仅使用一小部分C ++功能,否则C ++标准库在此处已被破坏.在构建GNU libstdc ++时(即在Google方面,当他们构建NDK时),在$NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/$ABI/include/bits/c++config.h中定义了(或未定义)宏_GLIBCXX_USE_C99.不幸的是,它基于非常有限的libc(Google的Bionic)构建,因此GNU libstdc ++配置脚本会检测到它并禁用某些部分(尤其是std::to_wstring),具体取决于libc中缺少的功能.

This is known problem of Google's Android NDK - C++ Standard Library is broken there, unless you're using just small subset of C++ functionality. Macro _GLIBCXX_USE_C99 is defined (or not defined) in $NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/$ABI/include/bits/c++config.h at the moment when GNU libstdc++ is building (i.e. on Google's side, when they build NDK). Unfortunately, it's built on top of very limited libc (Google's Bionic), so GNU libstdc++ configuration scripts detect it and disable some parts (in particular, std::to_wstring), depending on that absent functionality in libc.

这是我开始 CrystaX NDK (Android的替代本机开发套件)的主要原因之一.在CrystaX NDK中,我们特别注意libc,libstdc ++的完整性以及与标准的一致性. CrystaX NDK可以替代Google的Android NDK,因此很可能也可以与Visual Studio一起使用.

This is one of the main reason why I've started CrystaX NDK - alternative native development kit for Android. In CrystaX NDK, we pay special attention to completeness of libc, libstdc++, and conformance to standards in general. CrystaX NDK works as a drop-in replacement for Google's Android NDK, so most likely it will just work with Visual Studio too.

这篇关于_GLIBCXX_USE_C99未定义,to_wstring不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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