Compilation is normally encapsulated so that all of the necessary steps happen behind the scenes. Type the following C code into a file named count.c.
Compilation is normally encapsulated so that all of the necessary steps happen behind the scenes. Type the following C code into a file named
#define TARGET 10
for (i = 0; i < TARGET; ++i)
You can compile this code all at once with the following command.
You can verify with
ls that there are now two files:
count.c containing your source code, and
count, the executable program. (If you’re used to Windows where programs have a
.exe extension, you’ll have to get used to the tradition in UNIX that programs do not have an extension at all.) You can run the program and see it work by entering the following.
Note that we start from the preprocessed
.i file and that the traditional extension for the assembly language output is
.s. Again, have a look inside the resulting file—you are not expected to understand assembly language yet, but we will be learning a lot about it in the coming weeks.
Work through the example above. submit all of the files along the way: