How to substitute a libm.a math function?

61 views Asked by At

I want to test a new sqrt function to be used instead of the libm one. But both CLion and Netbeans use the libm one instead of mine (there is no need to say them to add -lm in linking).

For instance:

#include stdio.h>

double sqrt(double n) {
    printf("Starting\n");
    return 1.0;
}

int main () {
    printf("Root: %f\n", sqrt(4));
    return 0;
}

In Netbeans and CLion, this code does not execute my sqrt (never prints 'Starting' and returns 1.0). Instead, it executes sqrt in libm.a (even though math.h is not included), printing 2.0.

Is there any way to exclude -lm in linking in these IDEs? Do I have to change my function name (it works fine If I do so)?

Alberto

0

There are 0 answers