+ 3

Can we see the actual code of predefined function s in c language?

Such as sqrt, getch, sin, cosine, abs, atoi, atof,etc

5th Jul 2019, 7:21 AM
Sharma Abhishek
 Sharma Abhishek  - avatar
4 ответов
+ 2
How to open a header file
5th Jul 2019, 7:38 AM
Sharma Abhishek
 Sharma Abhishek  - avatar
+ 2
"actual code" I assume you're referring to the implementation of the standard library functions which their "declarations" (not implementations) are available in respective header files. For example, the declaration of `sqrt()` in `math.h` file is like _CRTIMP double __cdecl sqrt (double); Which means, the compiler only aware of the existence of `sqrt()` and it's the linker responsibility to find and link the `sqrt()`'s object code[1] to the client code before runtime. [1] Since the standard library's `*.c` files (implementations) are all pre-compiled (as object code), the only way to inspect the underlying implementation (which is different in each implementation) is through available repositories that holding the standard libraries sources. Here[2], you will see the `sqrt()`'s implementation and here[3] you'd find `__ieee754_sqrt()`'s being called by `sqrt()`. [2] https://github.com/bminor/glibc/blob/master/math/w_sqrt_compat.c [3] https://github.com/bminor/glibc/blob/master/sysdeps/ieee754/dbl-64/e_sqrt.c
5th Jul 2019, 9:22 AM
To Seek Glory in Battle is Glorious
To Seek Glory in Battle is Glorious - avatar
+ 1
You can, by opening the header file
5th Jul 2019, 7:37 AM
Agent_I
Agent_I - avatar
+ 1
Just open the file, like a source code
5th Jul 2019, 7:40 AM
Agent_I
Agent_I - avatar