C编译器从右到左或从左到右读取? [英] C compiler reads from right to left or left to right?

查看:290
本文介绍了C编译器从右到左或从左到右读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C编译器从右到左或从左到右读取?

可以用任何人描述它吗?

C compiler reads from right to left or left to right?
can any one describe it?

推荐答案

它读取开始于结束。你为什么要问?
It reads start to end. Why do you ask?


C编译器从文件的开头读到最后并完全处理每个语句,然后继续下一个。注明前向声明,并在遇到时填写详细信息。关于链接器的更多细节,我将在这里为您节省。



如果您询问源代码行中的逻辑表达式,编译器读取的顺序''无关紧要。然而有短路逻辑,例如



The C compiler reads from the beginning of the file to the end and processes each statement completely before moving on to the next. Forward declarations are noted and the details filled in as they are encountered. There are more details about the linker which I will spare you here.

If you are asking about logical expressions within a source line, the order that the compiler ''reads'' is irrelevant. There is short circuit logic however such that a statement such as

if(x && *x > 3)
{ ... }





从左到右执行,并在遇到错误条件时终止。



is executed from left to right and terminates when a false condition is encountered.


编译器如何读取输入是一个实现细节。如何评估语句或表达式有点复杂。例如,大多数表达式运算符都是左关联的(从左到右),但也要考虑运算符优先级(以及使用大括号)。

如果语句从左到右(带快捷方式),而逗号操作符从右到左。

您应该查看文档以获得洞察力。
How the compiler reads the input is an implementation detail. How the statements or expressions are evaluated is a bit complex. For instance most expression operators are left associative (that is are left to right) but there is also operator precedence (and the use of braces) to take into account.
Logical expressions in if statements are left to right (with shortcut) while the comma operator is right to left.
You should check out the documentation to get insight.


这篇关于C编译器从右到左或从左到右读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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