Nad*_*dav 2 visual-studio-code
VS Code (v1.63.2),在 Linux Ubuntu 18.04 上运行,在默认设置中将 CLOCK_MONOTONIC 表示为未定义。
#include <time.h>
...
struct timespec start_time;
(void) clock_gettime(CLOCK_MONOTONIC, &start_time);
Run Code Online (Sandbox Code Playgroud)
我应该如何配置 VS 代码来定义 CLOCK_MONOTONIC?
修复方法是编辑c_cpp_properties.json来使用gcc和定义_POSIX_C_SOURCE=199309L。例如:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_POSIX_C_SOURCE=199309L"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1335 次 |
| 最近记录: |