Clang> = 3.3在c ++ 1y模式下不能解析< cstdio>标题 [英] Clang >= 3.3 in c++1y mode cannot parse <cstdio> header

查看:452
本文介绍了Clang> = 3.3在c ++ 1y模式下不能解析< cstdio>标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,在c ++ 11模式下正确编译和运行在g ++ 4.8.1和clang> = 3.3下。然而,当我切换到实验 -std = c ++ 1y 模式时,clang 3.3(但不是g ++)阻塞在< cstdio&

I have a project that correctly compiles and runs under g++ 4.8.1 and clang >= 3.3 in c++11 mode. However, when I switch to the experimental -std=c++1y mode, clang 3.3 (but not g++) chokes on the <cstdio> header that is indirectly included by way of Boost.Test (so I cannot easily change it myself)

// /usr/include/c++/4.8/cstdio
#include <stdio.h>

// Get rid of those macros defined in <stdio.h> in lieu of real functions.
// ...
#undef gets
// ...    

namespace std
{
// ...
using ::gets; // <-- error with clang++ -std=c++1y
// ...
}

出现以下错误消息:


/ usr / lib / gcc / x86_64-linux-gnu / 4.8 /../../../../ include / c ++ / 4.8 / cstdio:119:11:
错误:在全局命名空间中没有名为gets的成员

/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/cstdio:119:11: error: no member named 'gets' in the global namespace

本教程中,介绍如何设置一个现代的C ++环境,遇到类似的查找问题与 max_align_t 。建议使用sed脚本用 #ifdef __clang __ 宏包围未知符号,但这似乎是一种脆弱的方法。

On this tutorial on how to set up a modern C++ environment, a similar lookup problem with max_align_t is encountered. The recommendation there is to use a sed script to surround the unknown symbols with #ifdef __clang__ macros, but that seems a fragile approach.

设置:普通64位Linux Mint 15与

Setup: plain 64-bit Linux Mint 15 with


g ++(Ubuntu 4.8.1-2ubuntu1〜13.04) 1

g++ (Ubuntu 4.8.1-2ubuntu1~13.04) 4.8.1

Ubuntu clang版本3.3-3〜raring1(branches / release_33)(基于
LLVM 3.3)

Ubuntu clang version 3.3-3~raring1 (branches/release_33) (based on LLVM 3.3)

问题


  • 导致此错误的原因是什么?有没有 __ clang __ 宏任何地方附近的代码有问题,clang在c ++ 11模式没有任何麻烦。

  • 这是一个语言问题(C ++ 14是否说关于从全局导入C兼容符号到 std namespace)?

  • 我需要更改包含路径的内容吗? (我使用CMake自动选择标题路径,并在CMakeLists.txt内切换模式)

  • clang是否有开关来解决此问题?

  • what is causing this erorr? There is no __clang__ macro anywhere near the code in question, and clang in c++11 mode has no trouble at all.
  • Is it a language problem (does C++14 say something else than C++11 about importing C compatible symbols from the global into the std namespace)?
  • Do I need to change something with my include paths? (I use CMake to automatically select the header paths, and switch modes inside CMakeLists.txt)
  • Does clang have a switch to resolve this?

推荐答案

gets
$ b

This note in the gets manpage looks relevant:


ISO C11删除了C语言中gets()的规范,并且从2.16开始,glibc头文件不公开函数声明,如果 _ISOC11_SOURCE 特性测试宏。

可能

#if !_ISOC11_SOURCE
using ::gets;
#endif

这篇关于Clang&gt; = 3.3在c ++ 1y模式下不能解析&lt; cstdio&gt;标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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