once.h でmultiple definition (2009-04-27 00:34 by akira #43446)
複数の.cppファイルでthread.hをincludeしているとmultiple definition の
リンクエラーになります。
/tmp/ccIiR5ho.o:(.data+0x0): multiple definition of `clx::detail::once_global_epoch'
/tmp/ccHB39Ej.o:(.data+0x0): first defined here
:
:
スマートな解決方法は無いでしょうか?
とりあえず#ifdefで初期化は特定のファイルだけにして他はexternにしましたが
まちがっているような気もするので正しいのかもお教えください。
RE: once.h でmultiple definition (2009-06-03 15:37 by akira #44172)
OSはLinux
ubuntu server v9.04
$ g++ example_thread.cpp
In file included from clx/thread.h:54,
from example_thread.cpp:36:
clx/unix/once.h: In constructor ‘clx::detail::global_condition::global_condition()’:
clx/unix/once.h:59: error: expected primary-expression before ‘{’ token
clx/unix/once.h:60: error: expected primary-expression before ‘{’ token
$ uname -a
Linux dev 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:48:10 UTC 2009 i686 GNU/Linux
$ gcc --version
gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.