Reputation: 99428
Sometimes when there are errors output by gcc, one will break down the the process for each stage of preprocessing, compilation, assembly, linking by options like -E, -S and -c. Here is an example.
I just wonder what types of errors could happen at each of these four stages and if there is one error occuring at one of these stages but not at previous stages, how will this guide you to locate the reason of the error and correct it?
Upvotes: 0
Views: 257
Reputation: 1019
If I remember well the meaning of each term:
Preprocessing error: `abcdefg' is not a valid keyword so preprocessing will fail:
#abcdefg
Compilation error: `fight!now' is not a valid identifier so compilation will fail:
int fight!now;
Linking error: `myfunc' is declared by never defined:
extern int myfunc();
int main() {
return myfunc();
}
You see, knowing where the tool chain detects the error helps knowing what kind of error it could be. But often the messages the tool chain emits is enough to understand where the error resides. Of course it requires being used to passing parameters as -Wall or even -Wextra to get more warnings about what could be wrong.
Upvotes: 1