Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
コードスニペットでclock_gettimeを使用し、フラグ-std = c99でコンパイルすると、次のようなエラーが発生しました。
warning: implicit declaration of function 'clock_gettime' error: 'CLOCK_REALTIME' undeclared (first use in this function)
そして私はファイル'time.h'を含めました。誰もがそれを修正する方法を知っています。
-std=c99 を使用して元のコードに追加してみてください
#define _POSIX_C_SOURCE >= 199309L
clock_gettime のマニュアル ページは、これが必要な機能テスト マクロ要件であることを示しています。