タグ付けされた質問 「timespec」

1
Cコードのtimespec_get()の秒コンポーネントの1秒遅れてtime()が報告する時間がなぜですか?
次のコードスニペット: struct timespec ts; for (int x = 0; x < 100000000; x++) { timespec_get(&ts, TIME_UTC); long cTime = (long) time(NULL); if (cTime != ts.tv_sec && ts.tv_nsec < 3000000) { printf("cTime: %ld\n", cTime); printf("ts.tv_sec: %ld\n", ts.tv_sec); printf("ts.tv_nsec: %ld\n", ts.tv_nsec); } } この出力を生成します: ... cTime: 1579268059 ts.tv_sec: 1579268060 ts.tv_nsec: 2527419 cTime: …
12 c  time  posix  timespec 
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.