コグノスケ


link 未来から過去へ表示(*)  link 過去から未来へ表示

link もっと前
2005年1月20日 >>> 2005年1月20日
link もっと後

2005年1月20日

研究室にてバグ取りをしました。スレッドが立ち上がる前に終了させると、今まで溜まっていたリクエストを無理やり空にしてしまう仕様にしていたためでした。とりあえず動いているようですし、解決できたかな。
テンプレートクラスに手を出してみたところ、変なエラーが出てきてリンクできません。他のオブジェクトにテンプレート関数があり、インラインコンストラクタではない場合(サンプルで言うとclass B<T>)、コンストラクタへの参照が解決できない、とかリンカがほざいてリンクしません。Aへの参照は解決しているくせに…なぜ。

a.cpp

#include "b.h"

template <class T> class A {
public:
  A(void);
  virtual ~A(void);
};
template <class T>
A<T>::A(void) {}
template <class T>
A<T>::~A(void) {}

int main()
{
  A<int *> a;
  B<int *> b;
  C<int *> c;

  return 0;
}
b.h

template <class T> class B {
 public:
  B(void);
  virtual ~B(void);
};

template <class T> class C {
 public:
  C(void) {};
  virtual ~C(void) {};
};
b.cpp

#include "b.h"

template <class T>
B<T>::B(void) {}
template <class T>
B<T>::~B(void) {}

コンパイルの結果はこんなかんじ。

コンパイル結果
$ g++ -c b.cpp a.cpp
$ g++ b.o a.o
a.o: In function `main':
a.o(.text+0x1d): undefined reference to `B<int *>::B(void)'
a.o(.text+0x4e): undefined reference to `B<int *>::~B(void)'
a.o(.text+0xaf): undefined reference to `B<int *>::~B(void)'
collect2: ld returned 1 exit status
編集者:すずき(2014/09/10 13:14)

コメント一覧

  • コメントはありません。
open/close この記事にコメントする



link もっと前
2005年1月20日 >>> 2005年1月20日
link もっと後

管理用メニュー

link 記事を新規作成

<2005>
<<<01>>>
------1
2345678
9101112131415
16171819202122
23242526272829
3031-----

最近のコメント5件

  • link 21年3月13日
    すずきさん (03/05 15:13)
    「あー、このプログラムがまずいんですね。ご...」
  • link 21年3月13日
    emkさん (03/05 12:44)
    「キャストでvolatileを外してアクセ...」
  • link 24年1月24日
    すずきさん (02/19 18:37)
    「簡単にできる方法はPowerShellの...」
  • link 24年1月24日
    KKKさん (02/19 02:30)
    「追伸です。\nネットで調べたらマイクロソ...」
  • link 24年1月24日
    KKKさん (02/19 02:25)
    「私もエラーで困ってます\n手動での回復パ...」

最近の記事3件

  • link 23年4月10日
    すずき (03/19 11:48)
    「[Linux - まとめリンク] 目次: Linuxカーネル、ドライバ関連。Linuxのstruct pageって何?Linu...」
  • link 24年3月18日
    すずき (03/19 11:47)
    「[画面のブランクを無効にする] 目次: LinuxROCK 3 model CのDebian bullseyeイメージは10分...」
  • link 24年3月3日
    すずき (03/19 11:07)
    「[解像度の設定を保存する] 目次: LinuxRaspberry Pi 3 Model B (以降RasPi 3B)のHDMI...」
link もっとみる

こんてんつ

open/close wiki
open/close Linux JM
open/close Java API

過去の日記

open/close 2002年
open/close 2003年
open/close 2004年
open/close 2005年
open/close 2006年
open/close 2007年
open/close 2008年
open/close 2009年
open/close 2010年
open/close 2011年
open/close 2012年
open/close 2013年
open/close 2014年
open/close 2015年
open/close 2016年
open/close 2017年
open/close 2018年
open/close 2019年
open/close 2020年
open/close 2021年
open/close 2022年
open/close 2023年
open/close 2024年
open/close 過去日記について

その他の情報

open/close アクセス統計
open/close サーバ一覧
open/close サイトの情報

合計:  counter total
本日:  counter today

link About www.katsuster.net
RDFファイル RSS 1.0

最終更新: 03/19 11:48