加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C中的指令#include和C中的指令有什么区别吗?

发布时间:2020-12-16 10:44:32 所属栏目:百科 来源:网络整理
导读:在帖子中没有回答这个问题#include filename之间的区别是什么?和#include“文件名”?这是一个不同的问题. 我正在研究C和C之间的差异.我通过比较您可以对每种语言进行的最基本的程序来做到这一点: 在C: #include stdio.hint main(){ printf("Hello World"
在帖子中没有回答这个问题#include< filename>之间的区别是什么?和#include“文件名”?这是一个不同的问题.
我正在研究C和C之间的差异.我通过比较您可以对每种语言进行的最基本的程序来做到这一点:

在C:

#include <stdio.h>
int main()
{
    printf("Hello World"); 
    return 0; 
}

在C.

#include <iostream>
int main()
{
  std::cout << "Hello World!!!" << std::endl;
  return 0;
}

我知道标题和编译过程.但我想知道C和C的#include指令之间是否有任何区别.例如,可能以不同的方式复制复制时的标题内容.
我认为这个问题非常简单,您可以通过说“不”或“是,这是差异:1),2)”来回答.

解决方法

是的,至少有两个不同之处.在C(WG21 N4567 [cpp.include] / 5):

The implementation shall provide unique mappings for sequences
consisting of one or more nondigits or digits (2.10) followed by a
period (.) and a single nondigit. The first character shall not be
a digit. The implementation may ignore distinctions of alphabetical
case.

在C(WG14 N1570 6.10.2 / 5,强调我的):

The implementation shall provide unique mappings for sequences
consisting of one or more nondigits or digits (6.4.2.1) followed by a
period (.) and a single nondigit. The first character shall not be a
digit. The implementation may ignore distinctions of alphabetical case
and restrict the mapping to eight significant characters before the
period
.

符合要求的C实现可以将“foobarbaz.h”和“foobarbat.h”映射到同一个源文件.符合C的实现不能.

另外,在C(N1570 6.4.7)中:

If the characters ',,",//,or /* occur in the sequence
between the < and > delimiters,the behavior is undefined.
Similarly,if the characters ',or /* occur in the
sequence between the " delimiters,the behavior is undefined.

在C中(N4567 [lex.header] / 2):

The appearance of either of the characters ' or or of either of
the character sequences /* or // in a q-char-sequence or an
h-char-sequence is conditionally-supported with implementation-defined semantics,as is the appearance of the
character " in an h-char-sequence.

“有条件地支持实现定义的语义”意味着

>如果实施不支持,则必须发布诊断;
>如果实现确实支持它,则必须记录其对此构造的解释.

而“未定义的行为”意味着实现可以做任何想做的事情.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读