CLOCK_REALTIME Is Undefined In Visual Studio But Can Run in Linux Target
Yik Heng Yong
0
Reputation points
Question:
Aside from just adding the error to the ignore list in Visual Studio, is there a way to get Visual Studio to recognize POSIX-related functions?
Visual Studio Version: Community 2022 (64-bit) v17.12.3
Workload: Linux development with C++
Code Snippet:
#include <stdio.h>
#include <time.h>
int main()
{
struct timespec ts;
double time;
clock_gettime(CLOCK_REALTIME, &ts);
time = ts.tv_sec + (ts.tv_nsec / 1e9);
printf("Time:%f\n", time);
return 0;
}
Error Code:
Linux Terminal Result:
pi@bpi-iot-ros-ai:~/projects/ConsoleApplication1$ ./main
Time:1736924024.770033
Troubleshooting Steps That Taken By Myself:
I tried to Update but the error persisted.
Sign in to answer