Given these two C programs
Function prototype and
after.c declaration
#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
d5b87a14479e764f1c8a8669182773a1 to
924ec57ea6ef7ee306edfd0ec7f5f7ecff
As you can see, it will create different binary files. Why is this so? What is so different before and after? Is there any difference in speed?
source
share