簡體   English   中英

未定義的引用與std :: atomic <const memberfunctionpointer*> 在g ++ 4.4中:: :: store()

[英]undefined reference with std::atomic<const memberfunctionpointer*>::store() in g++ 4.4

我有一個std::atomic ,它包含一個指向成員函數的指針。 在g ++ 4.4.5中一切都可以正常編譯,但是在鏈接期間出現此錯誤:

./pool.o: In function `pool::worker::worker(pool&, int, int)':
pool.cpp:(.text._ZN4pool6workerC1ERS_ii[pool::worker::worker(pool&, int, int)]+0x95): undefined reference to `std::atomic<void (pool::* const*)(unsigned int, unsigned int, pool::worker*)>::store(void (pool::* const*)(unsigned int, unsigned int, pool::worker*), std::memory_order) volatile'
./pool.o: In function `pool::worker::give_job(void (pool::* const&)(unsigned int, unsigned int, pool::worker*), unsigned int, unsigned int)':
pool.cpp:(.text._ZN4pool6worker8give_jobERKMS_FvjjPS0_Ejj[pool::worker::give_job(void (pool::* const&)(unsigned int, unsigned int, pool::worker*), unsigned int, unsigned int)]+0x142): undefined reference to `std::atomic<void (pool::* const*)(unsigned int, unsigned int, pool::worker*)>::store(void (pool::* const*)(unsigned int, unsigned int, pool::worker*), std::memory_order) volatile'
./pool.o: In function `pool::worker::soul()':
pool.cpp:(.text._ZN4pool6worker4soulEv[pool::worker::soul()]+0xf1): undefined reference to `std::atomic<void (pool::* const*)(unsigned int, unsigned int, pool::worker*)>::store(void (pool::* const*)(unsigned int, unsigned int, pool::worker*), std::memory_order) volatile'

我並沒有真正理解為什么它試圖鏈接到store()的易失性重載,在源中指向成員函數的指針是const ,而不是volatile (並且會編譯)。

相同的代碼使用g ++ 4.6.3編譯

很簡單:GCC 4.4沒有對此的支持,或者它以您的體驗方式被破壞了。 較新的GCC具有更好的支持,並且按應有的方式工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM