【问题标题】:why __thread gives linker error when printf statement is used?为什么使用 printf 语句时 __thread 会给出链接器错误?
【发布时间】:2016-06-13 12:45:29
【问题描述】:

这是我的示例程序,

int main()
{
   static __thread int a;

   printf("\n %d",a);

   return 0;
}

在这个程序中,当 printf 语句被删除时,它链接正常。 当包含 printf 语句时,它会给出以下链接器错误

ld: fatal: relocation error: R_SPARC_TLS_LE_HIX22: file /var/tmp//ccwb2Cxc.o: symbol <unknown>: bad symbol type SECT: symbol type must be TLS

处理器:SUN-SPARC 操作系统:UNIX

【问题讨论】:

    标签: c++ multithreading pthreads sparc thread-local-storage


    【解决方案1】:

    据我所知,这是自 2006 年以来 Sun 链接器的一个已知问题。如果您将整数复制到本地(非线程),它对您有用吗?

    【讨论】:

      猜你喜欢
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 2011-12-23
      • 1970-01-01
      • 2021-02-10
      • 1970-01-01
      • 1970-01-01
      • 2016-10-12
      相关资源
      最近更新 更多