如何使C ++ 0x和__STRICT_ANSI__走? [英] How can I make C++0x and __STRICT_ANSI__ get along?
问题描述
我需要在项目中使用 popen
,但我得到:
错误: popen'未在此范围中声明
看起来像GCC在<$ c下定义
__ STRICT_ANSI __
$ c> -std = c ++ 0x (与我找到的小信息相反)-std = gnu ++ 0x
,这将导致popen
(和_popen
)从stdio
。奇怪的是,undefined__ STRICT_ANSI __
不能解决问题,也不会转发声明函数。我显然缺少一些东西。是否有合理的解决方法?
我在4.5.0使用MinGW,升级到4.5.2,但仍然遇到同样的问题。
解决方案我可以使用msys来编译4.6.0
<$ c $ c> -std = gnu ++ 0x -U__STRICT_ANSI__
这可能是一个很好的理由,这样做,但它给了我想要的(C ++ 0x加GNU扩展,加上传统的东西仍然工作)。我一直在做这个很长一段时间,永远不会遇到麻烦。但如果它吃了你的猫,不要怪我。
I need to use
popen
in a project, but I get:error: 'popen' was not declared in this scopeIt looks like GCC defines
__STRICT_ANSI__
under both-std=c++0x
and (contrary to what little information I was able to find)-std=gnu++0x
, which causespopen
(and_popen
) to be elided fromstdio
. Oddly enough, undefining__STRICT_ANSI__
doesn't solve the issue, nor does forward-declaring the function. I'm obviously missing something. Is there a reasonable workaround?I was using MinGW with 4.5.0, and upgraded to 4.5.2, but am still experiencing the same problem. I'd rather not have to muck about with msys to compile 4.6.0, but I will if I must.
解决方案I'm simply undefining it on the commandline right away, this is not terribly "clean" but it works fine from what I can tell.
-std=gnu++0x -U__STRICT_ANSI__
There is probably a good reason why one should not do that, but it gives me what I want (C++0x plus GNU extensions, plus legacy stuff still works). I've been doing this for a long time and never run into trouble. But don't blame me if it eats your cat.
这篇关于如何使C ++ 0x和__STRICT_ANSI__走?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!