Boostのfile_lockはincludeするとそのままではコンパイルエラーになります。(ver.1.35)
もおー。困った子ねー。
ということで、回避方法を書いてみようと思います。
ただ、正式なHPなどに書いてあったものを見たわけではなく、いろいろ参考に独自に自分で試した結果なので間違っているかもしれないです。
ご了承ください。
対象:
Boostバージョン1.35のfile_lockに関わる箇所のみの修正です。
【ファイルの修正方法】
①文字化けの修正
interprocess/detail/config_begin.hpp
⇒20行目 non ・DLL-interfaceの・を削除する
interprocess/errors.hpp
⇒13,14行目 などの・やウの半角のような文字を削除する
②コードの修正(file_lock.hppだけです) interprocess/sync/file_lock.hpp
●165行目あたり: 同じ関数定義が2度記述されているのでコメントアウトする。
/*
bool timed_acquire_file_lock
(file_handle_t hnd, bool &acquired, const boost::posix_time::ptime &abs_time)
{
・・・中略
}
*/←232行目あたり
/// @endcond
●133,164行目あたり: 以下を追記
// relinquish current time slice
#if (defined BOOST_WINDOWS) && !(defined BOOST_DISABLE_WIN32)
winapi::sched_yield();
#else
::sleep(0);
#endif
●271行目あたり: detail:: を削除する
if(!timed_acquire_file_lock(m_file_hnd, result, abs_time)){
●307行目あたり: detail:: を削除する
if(!timed_acquire_file_lock_sharable(m_file_hnd, result, abs_time)){
●212行目あたり: detail:: を追記する
if(!detail::try_acquire_file_lock_sharable(hnd, acquired))
●150行目あたり: detail:: を追記する
if(!detail::try_acquire_file_lock_sharable(hnd, acquired))
●119行目あたり: detail:: を追記する
if(!detail::try_acquire_file_lock(hnd, acquired))
これで動くはずです。たぶん。
記載漏れはないと思うのだけどな。(ちょっと不安)
参考:
・ファイルロックをするには?(boostのfile_lock)