0

我从 main() 函数以及其他创建的线程中调用以下内容。虽然它在创建的线程中运行良好,但它在我的 main() 中返回了一个大的垃圾值。

long getTimeMilliSecs()
{
    struct timeval tempTime;
    gettimeofday(&tempTime, NULL);
    long retVal = 1000000*tempTime.tv_sec + tempTime.tv_usec;
    return retVal;
}

使用带有 gcc 的 Linux Ubuntu。有谁知道这种特殊行为的原因?谢谢你!

以这种方式使用它:

main()
{
:
   emuTime = getTimeMilliSecs();
}

线程端代码:

long time1 = getTimeMilliSecs();
printf("time1: %ld  emuTime: %ld\n", time1, emuTime);   


OUTPUT:
time1: 9006806 emuTime: 1380680868658357

类似的线程调用方式。


来自评论:更新!emuTime也是类型long

4

0 回答 0