8
以下「玩具」代碼表示我在使用POSIX timers的較大代碼庫中遇到的問題。錯誤:'struct sigevent'沒有名爲'sigev_notify_thread_id'的成員
#include <time.h>
#include <errno.h>
#include <signal.h>
#include <iostream>
using namespace std;
int main()
{
struct sigevent sevp;
long threadId = 5;
sevp.sigev_notify = SIGEV_THREAD_ID;
sevp.sigev_notify_thread_id = threadId;
return 0;
}
當我試圖在Linux機器上編譯使用g++
它,我得到的錯誤:
error: ‘struct sigevent’ has no member named ‘sigev_notify_thread_id’
有什麼理由? This使我相信sigevent
結構有一個名爲sigev_notify_thread_id
的成員。
Thanks @Duck。 'sevp._sigev_un._tid'和第295行「這裏 - http://lxr.free-electrons.com/source/include/uapi/asm-generic/siginfo.h#L295」解決了我的問題。發佈作爲答案,我會接受! – dinkelk