2017-01-09 1 views
0

:우분투는 "gettid"기능을 찾을 수 없습니까? 내가 스레드와 관련된 물건을 테스트하는 매우 작은 프로그램을 가지고

#include<unistd.h> 
#include<sys/types.h> 
#include<stdio.h> 
int main() 
{ 
    pid_t pid=getpid(); 
    pid_t tid=gettid(); 
    printf("%d,%d\n",pid,tid); 
    return 0; 
} 

정력 편집기, 나는 'gettid'에 집중하고 Shift 키 K를, gettid의 맨 페이지는 SYS/유형 내부 말한다.

g++ mythread.cpp 
mythread.cpp: In function ‘int main()’: 
mythread.cpp:7:22: error: ‘gettid’ was not declared in this scope 
    pid_t tid=gettid(); 
       ^

나는 새로운 버전의 gcc와 ubuntu1604에있어 : ​​아니 문제는, 내가 그것을 컴파일 할 때, 오류가 없습니다. 그것을 고치는 방법?

+0

가능한 범위의 [C++ gettid()가이 범위에서 선언되지 않았습니다.] (http://stackoverflow.com/questions/30680550/c-gettid-was-not-declared-in-this-scope) – ks1322

답변

2

사용 : pid_t tid = syscall (SYS_gettid); 로 직접 호출 할 수 없습니다.

관련 문제