I see a plenty of similar questions, which are duplicates (like 12074147), but most of them are concerned with mathematical functions implementation.
My question is more about C standard headers, like this one:
#include <math.h>
What I'd be happy to understand, how exactly does the math.h refer to any sin or cos implementation when it even doesn't mention them.
At least, I cannot find any such or similar words in the code (i.e. F12 key) and in files that get included in math.h? What am I missing?
In most implementations, the standard headers are implemented as files in a set of system directories, that declare the library macros, types and functions specified in the C Standard. The usually include other files which provide the system specific definitions appropriate for the compiler, library and target system.
If you did not find a prototype for
cosandsin, look again for#includeor#include_nextdirectives and you may eventually find the definitions. To help locate the system include files, use the-Ecommand line argument.On my system here is the output for
<math.h>:Note also that in addition to the above definitions, the compiler may implement its own semantics for standard functions and generate inlined or transformed code for many of them.
For example, it is not uncommon for compilers to optimize
printf("Hello word!\n")as a call toputs("Hello world!")and inline calls tosin(e)andcos(e)for constant argument expressions.