So, it's getting more interesting but we'll soon see that things don't always compile as easily as this command suggests.
更有意思了,但我们很快就会发现,并不是所有的编译都,像这条命令这么简单。
And the third one I want to point out is, whether this is an interpreted versus a compiled language.
我想说的第三件事情是,这个语言是编译语言,还是解释语言。
So I just realized this is a new MacBook Pro that I didn't actually download the compiler onto it apparently.
所以,我才意识到这是一台新电脑,显然我并没有把编译器安装到上面。
> So this time I had the foresight to install this compiler but what I'm gonna do is this.
>,这次我非常有先见之明地,安装了这个编译器,但是我这次要做的却是。
So really, once we start writing more interesting programs, you would have to type out long annoying commands like that to just compile more sophisticated programs.
实际上,一旦我们开始写一些更复杂的程序时,你们可能要键入那样一些长的,讨厌的命令,来编译跟高级的程序。
In a compiled language, you have an intermediate step, in which you take the source code, it runs through what's called a checker or a compiler or both, and it creates what's called object code.
而在编译语言里,你就会经过一个中间的步骤,在这种语言里输入源码后,先经过过滤器,或者编译器检查后,它会创建一个叫做目标代码的东西。
So let me challenge you with this: inside of these curly braces where I have put a comment with slash slash -- a "comment" means nothing here gets compiled, it's just for the human to read.
让我用这个来挑战你们:,在这些花括号里面,我通过双斜杠写入了一个注释,-一条“注释“在这里不会被编译,它只是用来我们阅读的。
So you're implementing this black box, and if its purpose in life is to actually return a value, you have to tell the compiler what kind of value to expect, and this is going to have ripple effects.
你在实现这个黑盒子,如果它的目的是,返回一个值,你必须告诉编译器你期望的是什么类型的值,这个将是一个连锁反应。
I'm going to throw it, or raise it, to use the right term to somebody in case they can handle it, but it's a particular kind of exception I might do something like, remind you I have test.
编译器就要抛出他或者提出它,用正确的描述给某个人来处理,但他的确是一种异常,我来做些类似的事情,告诉你我有些测试。
f2c So I'm going to go ahead and run make on f2c, which is the name I gave to this particular program.
所以我将继续来编译,这是我给这个程序取的名字。
You can't just take a quoted string back to back with another quoted string so you'd get some kind of compiler error.
你不能让一个引起来的字符串跟另一个引起来的字符串,背靠背,这样编译就会出错。
My prototype, again, so that I can use it later increment without the compiler wondering what is this increment that you're referring to because it's not otherwise been declared.
我的函数原型,再次强调,我可以以后使用它,这样编译器就不会疑惑这个你提及的,是什么,因为是没有,被声明的。
In a high-level language, square root might simply be a primitive that you can use rather than you having to go over and code it.
一个高级的语言,平方根可能仅仅,只是你能使用的一个基本要素,而不是你需要去编译它。
progress2 So let me go ahead and compile progress2 instead and this time run this one.
让我们继续来编译,这次运行这个程序。
It turns out you can list one, give it a name, and if you use square brackets, that tells the compiler I actually want to put multiple values inside of this -- inside of this variable and how do we do that?
结果是你可以列举一个,给它取个名字,如果你使用方括号,那是告诉编译器,在里面我需要许多的值--在这些变量里,我怎么做到的?
And let me go ahead and run-- how do I compile this?
继续运行,大家还记得怎么编译吗?
So, thankfully, C does provide a solution for this, whereby, I can provide a hint, essentially, to the compiler.
幸亏,C为这个提供了一个解决方案,那样,本质上,我可以给编译器一个提示。
It says you gave me something I didn't know how to deal.
它的意思是你给了编译器一个,他不知道怎么处理的东西。
In fact, this example would compile because you can use curly braces in this way to encapsulate lines of code, but realize for now, that, not good.
实际上,这个例子可以编译,因为你可以用这种方式来压缩代码行,但是请认识到,那个,不太好。
So what that means is the compiler is actually going to first "cast" so to speak 13 from whatever it is - to a float -- to a floating point value -- and then perform the division for us.
所以这里的意思是编译器将,做“计算“,譬如13这样一个浮点数,-到另一个浮点数-,然后为我们处理除法。
Now if I am difficult with the user positive1 and I compile make positive1, and I then run positive1.
现在如果我和用户有点不和谐,我编译正positive1,然后运行。
A compiled language is usually much faster in terms of its execution.
编译语言,要比它快一些。
If you're writing a program and you're testing it and recompiling.
如果你写一个程序,检测,然后重新编译。
Now as an aside, this may very well compile.
此外,这个可以很好地编译。
There are no syntax errors so it does compile.
这里没有语法错误,所以它通过编译了。
Let me go ahead and make, don't do this.
我们继续编译,不要这样做。
You don't have to re-implement the function.
你不需要重新编译那个函数。
I just reran make or GCC does it for me, and now I've got all these errors. Well, let's see.
我刚重新运行了make,或者GCC为我编译了代码,现在我得到了这些错误,好的,让我们看看。
Let me go ahead and compile this.
我们接着编译。
Let me go ahead and recompile.
让我们继续重新编译。
应用推荐