as said last week, make
isn’t actually the compiler. instead, the compiler is a program called clang
. make is just a quicker way to call clang that automatically populates the parameters for you, because clang commands actually get pretty long.
clang
is gcc
why? because you need to link in any libraries that you’re using by naming them in the clang
command:
why didn’t we have to include a link like -lstdio
too? well, stdio is just special, since it’s SO universally used; the compiler already links it by default without having to type it out.
note the difference between an “undefined reference” due to “linker command failed” with clang
, and the other kind of error make
will give if you didn’t include the right header.
“linker command failed” doesn’t mean that anything is wrong with your code itself.
4 steps that happen when you compile code:
preprocessing
[?] do preprocessing directives need to be at the top of the file in order for the compiler to find them, or is that just convention?
[?] how does it know where on the hard drive to find the header file anyway, since it’s not in the same directory as the .c file?
hey there’s also decompiling! that’s like what the TOC always tells you not to do!
every element of an array has to be the same type
in C, you can’t “ask the array how big it is”, you the programmer need to know
average(array)
call on that global variable to define its loop etc, but it would be better design if instead you defined your function as average(array, length)
and then the loop etc would be in terms of just local variablesdeclare arrays like int scores[3];
where 3 is the length of the array
int scores[];
and don’t give a length?strings are just arrays of chars in c
stringname[i]