Mac/iPhone: Is there a way to get a thread identifier without using Objective-C?

前端 未结 4 1351
南旧
南旧 2021-02-02 16:40

Is there a way to get any kind of thread identifier of the currently running thread without resorting to Objective-C\'s NSThread.

I\'m improving our custom debug tracing

4条回答
  •  猫巷女王i
    2021-02-02 16:59

    I appreciate this is a pretty old question.

    To get the same Thread ID that is reported in macOS's Console.app I used:

    uint64_t tid;
    pthread_threadid_np(NULL, &tid);
    printf("%#08x\nr", (unsigned int) tid);
    

    A screenshot from Console.app on macOS.

提交回复
热议问题