When are whitespace significant in translation phases 5 and 6 in C language?

To recap, the phases 5-7 are described in the standard: Each source character set member and escape sequence in character constants and string literals is converted to the corresponding member of the execution character set; if there is no corresponding member, it is converted to an implementation- defined member other than the null (wide) character. 7) Adjacent string literal tokens are co

在C语言的翻译阶段5和6中,什么时候空白显着?

回顾一下,标准中描述了阶段5-7: 字符常量和字符串文字中的每个源字符集成员和转义序列都被转换为执行字符集的相应成员; 如果没有相应的成员,则将其转换为除空(宽)字符以外的实现定义的成员。 7) 相邻的字符串文字标记被连接在一起。 分隔令牌的空白字符不再重要。 每个预处理令牌都被转换为令牌。 所产生的令牌在语法和语义上被分析并翻译为翻译单元。 现在我同意第7阶段的空白字符不再显着,但在阶段4之后已

C translation phases concrete examples

According to the C11 standard (5.1.1.2 Translation phases) there are 8 translation phases. Can anyone give a concrete example for each of the phases. For example at phase 1 there is: Physical source file multibyte characters are mapped, in an implementation- defined manner, to the source character set... so can I have an example of what happens when that mapping is executed and so on for oth

C翻译阶段的具体例子

根据C11标准(5.1.1.2翻译阶段),有8个翻译阶段。 任何人都可以给出每个阶段的具体例子。 例如在第一阶段有: 物理源文件多字节字符以实​​现定义的方式映射到源字符集... 所以我可以举一个例子,说明执行该映射时会发生什么,以及其他阶段如何? 那么,第一阶段的一个例子就是将源代码存储为面向记录的格式,例如在大型机上的z / OS中。 这些数据集具有固定的记录大小,因此,如果您的数据集规格为FB80(固定,阻止

printing a binary tree in C (and other imperative languages)

(First-time poster and rather new in programming, so be patient, please!) I'm interested in both an efficient general algorithm for printing formatted binary trees (in a CLI environment) and a C implementation. Here is some code that I wrote myself for fun (this is a much simplified version of the original and part of a larger program supporting many BST operations, but it should compile j

用C(和其他命令式语言)打印二叉树

(首次海报,而且在编程方面很新颖,请耐心等待!) 我对用于打印格式化二叉树(在CLI环境中)和C实现中的高效通用算法感兴趣。 这里有一些代码是我自己编写的,它们是为了好玩而编写的(这是一个原始版本的简化版本,是支持许多BST操作的大型程序的一部分,但它应该编译得很好): #include <stdbool.h> // C99, boolean type support #include <stdio.h> #include <stdlib.h> #include <math.h>

Why is C so fast, and why aren't other languages as fast or faster?

In listening to the StackOverflow podcast, the jab keeps coming up that "real programmers" write in C, and that C is so much faster because it's "close to the machine." Leaving the former assertion for another post, what is special about C that allows it to be faster than other languages? Or put another way: what's to stop other languages from being able to compile d

为什么C如此之快,为什么不是其他语言更快或更快?

在收听StackOverflow播客时,刺拳持续出现“真正的程序员”用C编写,并且C更快,因为它“靠近机器”。 如果把前面的断言留给另一篇文章,C的特殊之处在于它比其他语言更快? 或者换一种说法:阻止其他语言能够编译成与C一样快速运行的二进制文件? 对C来说没什么特别的。这就是速度很快的原因之一。 支持垃圾收集,动态输入和其他便于程序员编写程序的设备的新语言。 问题是,还有额外的处理开销会降低应用程序的性能。 C没

Why does the smallest int, −2147483648, have type 'long'?

This question already has an answer here: Why is 0 < -0x80000000? 6 answers (-2147483648> 0) returns true in C++? 4 answers In C, -2147483648 is not an integer constant. 2147483648 is an integer constant, and - is just a unary operator applied to it, yielding a constant expression. The value of 2147483648 does not fit in an int (it's one too large, 2147483647 is typically the

为什么最小的int,-2147483648,类型是'long'?

这个问题在这里已经有了答案: 为什么是0 <-0x80000000? 6个答案 (-2147483648> 0)在C ++中返回true? 4个答案 在C中, -2147483648不是整数常量。 2147483648是一个整数常量,并且-只是一个应用于它的一元运算符,产生一个常量表达式。 2147483648的值不适合int (它太大了, 2147483647通常是最大的整数),因此整数常量的类型为long ,这会导致您观察到的问题。 如果您想提到int下限,请使用<limits.h

Why does i = ++i invoke undefined behaviour?

This question already has an answer here: Why are these constructs (using ++) undefined behavior in C? 13 answers You are missing something about undefined behavior. Undefined behavior simply means the compiler can do whatever it wants. It can throw an error, it can (as GCC does) show a warning, it can cause demons to fly out of your nose. The primary thing is, it won't behave well an

为什么我= ++我调用未定义的行为?

这个问题在这里已经有了答案: 为什么这些构造(使用++)在C中的未定义行为? 13个答案 你错过了一些未定义的行为。 未定义的行为只是意味着编译器可以做任何想做的事情。 它可以抛出一个错误,它可以(如GCC所示)显示一个警告,它可以导致恶魔飞出你的鼻子。 最主要的是,它不会表现良好,编译器之间的行为也不一致,所以不要这样做! 在这种情况下,编译器不必在返回语句的rhs之前让操作符的lhs的副作用完成。 这

sequence points in c

A sequence point in imperative programming defines any point in a computer program's execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed. What does this mean? Can somebody please explain it in simple words? When a sequence point occurs, it basically means that y

序列点在c

命令性编程中的一个顺序点定义了计算机程序执行过程中的任何点,在此点上可确保先前评估的所有副作用都已执行,并且后续评估的副作用尚未执行。 这是什么意思? 有人可以用简单的话来解释吗? 当发生顺序点时,它基本上意味着您保证以前的所有操作都已完成。 在没有插入序列点的情况下更改变量两次是未定义行为的一个示例。 例如, i = i++; 是不确定的,因为对i的两次更改之间没有顺序点。 维基百科列出了C和C ++标

Git cant diff or merge .cs file in utf

A friend and I were working on the same .cs file at the same time and when there's a merge conflict git points out there's a conflict but the file isnt loaded with the usual "HEAD" ">>>" stuff because the .cs files were binary files. So we added numerous things (*.cs text and so on)- to our .gitattributes file to make git treat it as a text file which didnt w

Git不能差异或合并UTF文件中的.cs文件

一位朋友和我在同一时间处理同一个.cs文件,当发生合并冲突时,git指出存在冲突,但该文件未加载通常的“HEAD”“>>>”内容,因为.cs文件是二进制文件。 所以我们添加了很多东西(* .cs文本等等) - 我们的.gitattributes文件让git把它当作一个没有用的文本文件。 那就是当我们意识到git可以区别其他.cs文件而不是这个。 原因是因为它包含一些中文字符,所以它在unicode编码中。 那么我们如何制作git diff或合并utf-1

Prefix operator difference in C++ and C#

This question already has an answer here: Undefined behavior and sequence points 4 answers Pre & post increment operator behavior in C, C++, Java, & C# [duplicate] 6 answers It's undefined behaviour in C++. You are trying to modify value more than one time without sequence points (per C++98/03 standards). About C++11 The value computations of the operands of an operator are

C ++和C#中的前缀运算符差异

这个问题在这里已经有了答案: 未定义的行为和序列点4个答案 在C,C ++,Java和C#中增加和增加运算符行为6个答案 它在C ++中是undefined behaviour 。 您正试图在没有sequence points情况下多次修改值(按照C ++ 98/03标准)。 关于C ++ 11 运算符操作数的值计算在运算符结果的值计算之前排序。 如果对标量对象的副作用相对于同一标量对象的另一副作用或使用同一标量对象的值进行值计算而言是不确定的,则行为是未

Pre & post increment operator behavior in C, C++, Java, & C#

This question already has an answer here: Why are these constructs (using ++) undefined behavior in C? 13 answers Undefined behavior and sequence points 4 answers How are java increment statements evaluated in complex expressions 1 answer C# Pre- & Post Increment confusions 6 answers Java and C# evaluate expressions from left to right, and the side-effects are visible immediately.

在C,C ++,Java和C#中增加和增加运算符行为

这个问题在这里已经有了答案: 为什么这些构造(使用++)在C中的未定义行为? 13个答案 未定义的行为和序列点4个答案 如何在复杂表达式中评估Java增量语句1回答 C#前后增量混淆6个答案 Java和C#从左到右评估表达式,并且副作用立即可见。 在C ++中,子表达式的评估顺序是未指定的,并且修改同一个对象两次而没有中间顺序点是未定义的行为。 我没有时间详细描述C ++,C,C#和Java之间的区别。 我只会说,前后