C++ gettid() was not declared in this scope

前端 未结 3 2115
轻奢々
轻奢々 2020-12-28 17:32

A simple program is: I would like to get the thread ID of both of the threads using this gettid function. I do not want to do the sysCall directly. I want to use this funct

3条回答
  •  长发绾君心
    2020-12-28 18:04

    Additional to the solution provided by Glenn Maynard it might be appropriate to check the glibc version and only if it is lower than 2.30 define the suggested macro for gettid().

    #if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
    #include 
    #define gettid() syscall(SYS_gettid)
    #endif
    

提交回复
热议问题