[問題] 在不同thread new delete可以嗎?

看板C_and_CPP (C/C++)作者 (三億兩千萬大散戶)時間16年前 (2009/02/21 23:08), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串1/1
我用BCB6 我在某個thread new char[256] PostMessage給另一個thread 然後在另外一個thread delete[]該new出來的char pointer 請問這樣會有問題嗎? 表面上看起來應該OK 但是CodeGuard卻一直說Bad parameter, Function failure 還是compiler要家哪些設定或是參數呢? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 115.83.130.162

02/22 00:26, , 1F
thread只有獨立的stack,tls,pc,id 其他都是共享的,一樣的
02/22 00:26, 1F

02/22 00:27, , 2F
所以照理說是沒問題的
02/22 00:27, 2F
也許是BCB6 CodeGuard的問題吧 因為我試過在不同thread使用STL的insert/erase同一個set container CodeGuard並沒有任何錯誤訊息 但是new/delete, malloc/free的確有Bad parameter的錯誤訊息 也許是假的錯誤訊息吧 ※ 編輯: meltice 來自: 115.83.162.25 (02/22 16:15)
文章代碼(AID): #19e1aAua (C_and_CPP)
文章代碼(AID): #19e1aAua (C_and_CPP)