系统标题和正常标题gcc [英] System Header and normal header gcc

查看:173
本文介绍了系统标题和正常标题gcc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个非常愚蠢的问题,但我无法区分gcc中的系统头和普通头。



请参阅此链接
$ b


<2.8>系统头文件



头文件声明与操作系统的接口和
运行时库通常不能严格符合C.
因此, GCC提供了在系统头文件中找到的代码特殊处理
当GCC正在处理系统标题时,所有由'#warning'生成的警告(请参阅
诊断)都会被抑制。
系统头文件中定义的宏无论在哪里扩展,都可以免除一些警告
。当我们发现由于系统头文件中定义的宏中的代码而导致警告产生大量误报
时,这种豁免被授予临时



通常,只有在特定目录中找到的标题是
被视为系统标题。这些目录是在编译GCC
时确定的。但是,有两种方法可以将常规标题制作成
系统标题:

添加到搜索中的目录中找到的标题文件出于诊断目的,将-isystem和-idirafter命令行选项的路径视为系统
标题。
还有一个指令#pragma GCC system_header,它告诉GCC将当前包含文件的其余部分视为系统头文件
,无论它在哪里找到。在
中的#pragma之前的代码不受影响。 #pragma GCC system_header在
主要源文件中无效。


我欣赏一个显示系统头部内容的答案如果可能的话,以及在链接中讨论什么样的警告或特殊处理。 解决方案

系统头文件是头文件OS或编译器,并且位于Unix上的 / usr / include 目录中。正常的头文件是其他的东西,比如你自己写的头文件,或者是下载的应用程序或库附带的文件。


I know it is a very stupid question but I cannot get the difference between system header and normal header in gcc.

Refering to this link:

2.8 System Headers

The header files declaring interfaces to the operating system and runtime libraries often cannot be written in strictly conforming C. Therefore, GCC gives code found in system headers special treatment. All warnings, other than those generated by ‘#warning’ (see Diagnostics), are suppressed while GCC is processing a system header. Macros defined in a system header are immune to a few warnings wherever they are expanded. This immunity is granted on an ad-hoc basis, when we find that a warning generates lots of false positives because of code in macros defined in system headers.

Normally, only the headers found in specific directories are considered system headers. These directories are determined when GCC is compiled. There are, however, two ways to make normal headers into system headers:

Header files found in directories added to the search path with the -isystem and -idirafter command-line options are treated as system headers for the purposes of diagnostics. There is also a directive, #pragma GCC system_header, which tells GCC to consider the rest of the current include file a system header, no matter where it was found. Code that comes before the ‘#pragma’ in the file is not affected. #pragma GCC system_header has no effect in the primary source file.

I appreciate an answer showing some contents of system header if possible and what kind of warnings or special treatment is talking about in the link.

解决方案

System headers are header files that come with the OS or compiler, and are located in directories like /usr/include on Unix. Normal headers are everything else, such as the header files you write yourself, or files that come with an application or library you download.

这篇关于系统标题和正常标题gcc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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