How to include "time" library in the compiler?

0

I'm compiling in C on my Mac through the terminal, this is all a wonder, the only problem is that when I need to call a new library I do not know which command to call it by the terminal.

Ex: #include <stdio.h> is -std=c99

I do not know where I can find the terminal versions of the function call, now I'm trying to call the time.h library unsuccessfully because if I try something like -time does not compile, do you know where I find this information?

    
asked by anonymous 26.09.2015 / 23:31

2 answers

3

You have to use #include <time.h> within your code. This should suffice because both the header and the library itself are in the same place as the one you have already used and worked.

-std=c99 has nothing to do with include .

    
26.09.2015 / 23:38
0

(as @bigown already replied) in principle cc -o exemplo exemplo.c would arrive in this case.

some notes (some details may vary with the operating system):

  • Typically, time.h (just like other .h files) contains only the function declarations (and some types), they do not define them. So it's not libraries but just statements. The definitions of these functions are contained in the C base library (something like libc) along with a few hundred other functions.

  • When we need functions that do not belong to the C library (eg sqrt() ), we will include its declaration (#include) and add its library ( -lm ) to the compilation line. When the compiler finds p -lm it will look for the library ( .../libm.a or .so or something similar) that contains the compiled definition of these functions.

  • o -std=c99 (which as @bigown had said little influences this issue) only changes the warnings type, the set of extensions that go be tolerated by the compiler.

  • 02.10.2015 / 16:45