Re: [問題] template function包成dll

看板C_and_CPP (C/C++)作者 (實況「野球」魂)時間16年前 (2009/10/21 10:56), 編輯推噓3(308)
留言11則, 5人參與, 最新討論串2/2 (看更多)
※ 引述《mida (實況「野球」魂)》之銘言: : 標題: [問題] template function包成dll : 時間: Tue Oct 20 17:20:58 2009 : 我用VC6寫了一個dll,裡頭有一個class, : 包含一個template function, : compile OK。 : 可是檔案產生後,我用depend看dll, : 那個template function並沒有在其中, : 所以無法透過此dll使用這個function, : 請問這大概會是什麼問題呀? : → adxis:沒有export吧? 可以查msdn 我記得有dll walkthrough 10/20 17:29 : 推 LPH66:template function 好像是要用到才具現化 10/21 00:38 : → WPC001:建議再仔細看看什麼是template吧... 10/21 01:17 我有export喔,因為我如果把這個function改成固定type,例:int 就可以使用了。 所以是因為dll本身並沒有使用到這個function, 根本就不會有這塊記憶體存在, 我才無法用depend看到這個function吧? 不過這2個東西各有各的好處, 有沒有什麼小撇步可以讓兩者的優點結合在一起呢? 該不會要把所有有可能的type先在dll裡頭偷偷執行一遍, 才能在外部使用這個template function吧?冏 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.135.250.104

10/21 11:01, , 1F
10/21 11:01, 1F

10/21 11:43, , 2F
C++ 的保留字 export 跟危卵的 DLL export 是兩回事哦XD
10/21 11:43, 2F

10/21 16:18, , 3F
感謝大家,看來這是件小麻煩的事,我要花點時間研究一下^^"
10/21 16:18, 3F

10/21 17:19, , 4F
應該是function template吧。template多以原始碼的型式
10/21 17:19, 4F

10/21 17:20, , 5F
release。像boost就是一個例子。
10/21 17:20, 5F

10/21 17:22, , 6F
MS VC目前還不能export template成DLL吧。
10/21 17:22, 6F

10/21 17:23, , 7F
不過好像C++/CLI有這種東西。C++/CLI可以在run time時期指定
10/21 17:23, 7F

10/21 17:24, , 8F
template parameter的型態。
10/21 17:24, 8F

10/21 17:25, , 9F
所以說可以export到DLL!?很久沒研究C++/CLI...
10/21 17:25, 9F

10/21 17:26, , 10F
原po其實export的是function,不是function template。
10/21 17:26, 10F

10/23 18:18, , 11F
目前只有vector可以export成dll
10/23 18:18, 11F
文章代碼(AID): #1AtdXB_d (C_and_CPP)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
文章代碼(AID): #1AtdXB_d (C_and_CPP)