Given these two C programs
Function prototype and declaration
after.c
#include<stdio.h>
void hi();
int main(){
hi();
return 0;
}
void hi(){
puts("hello world");
}
Function definition only
before.c
#include<stdio.h>
void hi(){
puts("hello world");
}
int main(){
hi();
return 0;
}
compiled with:
cc -oafter after.c
cc -obefore before.c
md5sum *
efac7a08389095a718b7fc9e163719ca after
41e81298acdf96091b4a9326a4557b0c after.c
d5b87a14479e764f1c8a8669182773a1 before
924ec57ea6ef7ee306edfd0ec7f5fd54 before.c
As you can see, it will produce different binaries. Why is this so? What's so different about before and after? Is there a speed difference?