I'm calling clock_gettime with CLOCK_REALTIME to measure the time elapsed for a program of mine. The code is like this:
clock_gettime(CLOCK_REALTIME, &start);
int retCode = system(completeString.c_str());
clock_gettime(CLOCK_REALTIME, &finish);
and it gives me this errors when i try to compile it with gcc -lrt -o timeSpent.exe time.cpp:
time.cpp: In function 'int main(int, char**)':
time.cpp:38:18: error: 'CLOCK_REALTIME' was not declared in this scope clock_gettime(CLOCK_REALTIME, &start);
time.cpp:38:40: error: 'clock_gettime' was not declared in this scope clock_gettime(CLOCK_REALTIME, &start);
Header files:
#include <iostream>
#include <sstream>
#include <fstream>
#include <ctime>
#include <Windows.h>
Compiler: MinGW
I hope one of you guys is able to help me fix this problem, and i'm grateful for anyone who tries to help.
Ps: I'm using Windows 10, but i have been successful on compiling this same code before on a Win10 PC. Unfortunately i can't access it, since I'm in another country.
Ps²: I've already tried to #define _POSIX_C_SOURCE 199309L, the only thing it does is add a warning.