By experimenting with this simple code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double sin (double i){
printf("Yes!\n");
return 0.;
}
int main() {
printf("Do I run my version of sin()?: %lf\n", sin(1));
return 0;
}
I expected to find the function sin "shadowed" by my version, as for instance described in this thread (Overriding C library functions, calling original).
Surprisingly (to my viewpoint), when I compiled, gcc example.c
, (same effects with gcc example.c -lm
) I just obtained the mathematical value of sin. May I ask the reason of that? What should I change to use my definition?
This question aims to a better understanding of the language; I am not trying to solve any specific practical problem.