C++ 筆記

2006/02/17  ~ 阿亮 ~
  • Alarm Clock
    • 在 Solaris 下,有時會出現 "ALARM CLOCK",然後中斷。
    • 有可能是 usleep() 等造成的? 不太確定。
    • 方法:略去 SIGALRM 的 signal.
      • signal(SIGALRM, SIG_IGN);
  • 在 DLL 內實作 template class 有煩人的 explicit instantiation 的問題...
    • 參考這裡 
    • 另一篇有關 Template 實作的文章: 這裡 ,有一段 the "traditional" way of organizing source code (declarations in *.h files, and definitions in *.cpp files) does not work with templates,所以,我看到的 template 實作似乎都是整個放在 .h 。
    • 結論在 DLL 內實作 template class 有點煩人。
  • 少用 strdup,用 new/delete
    • 這樣常常會有問題 (不知為什麼?)
      • string pSrc;
      • strdup(pTarget, pSrc.c_str());
      • free(pTarget);
    • 改用這樣就沒問題
      • string pSrc;
      • pTarget = new char[pSrc.length()+1];
      • delete []pTarget;
加入書籤:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • Furl
  • Hemidemi
  • MyShare
  • Technorati
  • YahooMyWeb
  • BlogMemes Cn
  • Haohao
  • MisterWong
  • Netscape
  • Slashdot
  • funP

相關文章

  • No Related Post

歡迎留言

敝站會審核留言的適宜性,您的留言可能會較晚發佈,而且小弟保留刪除的權利!!

以下圖像請用滑鼠「拖曳」到編輯區即可用