close
使用 gettid 獲取 thread id, compile 卻發生 error -> error: ‘gettid’ was not declared in this scope
照定義, 應該只要 include <sys/types.h> 即可,
但事與願違 ...
最後才找到有人分享 workaround
#include <unistd.h>
#include <sys/syscall.h>
#define gettid() syscall(SYS_gettid)
Reference:
1. gettid definition
http://man7.org/linux/man-pages/man2/gettid.2.html
2. solution to error -> error: ‘gettid’ was not declared in this scope
https://stackoverflow.com/questions/30680550/c-gettid-was-not-declared-in-this-scope
全站熱搜