#1862 closed Bugs (fixed)
file_lock.hpp will not compile - at least under MSVC8
Reported by: | Owned by: | Ion Gaztañaga | |
---|---|---|---|
Milestone: | Component: | interprocess | |
Version: | Boost 1.35.0 | Severity: | Problem |
Keywords: | file_lock | Cc: |
Description
Hi,
I'm attempting to use interprocess::file_lock in 1.35.0. Unfortunately, it will not compile at all in my environment, which is Microsoft Visual Studio 2005 on WinXP. Merely #include'ing boost/interprocess/sync/file_lock.hpp causes this failure mode.
A summary of the errors:
<...> boost/interprocess/sync/file_lock.hpp(167) : error C2535: 'bool boost::interprocess::file_lock::timed_acquire_file_lock(boost::interprocess::file_handle_t,bool &,const boost::posix_time::ptime &)' : member function already defined or declared e:\dev\cub\boost\boost/interprocess/sync/file_lock.hpp(110) : see declaration of 'boost::interprocess::file_lock::timed_acquire_file_lock' <...> boost/interprocess/sync/file_lock.hpp(195) : error C2535: 'bool boost::interprocess::file_lock::timed_acquire_file_lock_sharable(boost::interprocess::file_handle_t,bool &,const boost::posix_time::ptime &)' : member function already defined or declared e:\dev\cub\boost\boost/interprocess/sync/file_lock.hpp(138) : see declaration of 'boost::interprocess::file_lock::timed_acquire_file_lock_sharable' <...> boost/interprocess/sync/file_lock.hpp(119) : error C3861: 'try_acquire_file_lock': identifier not found <...> boost/interprocess/sync/file_lock.hpp(147) : error C3861: 'try_acquire_file_lock_sharable': identifier not found <...> boost/interprocess/sync/file_lock.hpp(175) : error C3861: 'try_acquire_file_lock': identifier not found <...> boost/interprocess/sync/file_lock.hpp(188) : error C3861: 'sleep': identifier not found <...> boost/interprocess/sync/file_lock.hpp(203) : error C3861: 'try_acquire_file_lock_sharable': identifier not found <...> boost/interprocess/sync/file_lock.hpp(262) : error C2039: 'timed_acquire_file_lock' : is not a member of 'boost::interprocess::detail' <...> boost/interprocess/sync/file_lock.hpp(298) : error C2039: 'timed_acquire_file_lock_sharable' : is not a member of 'boost::interprocess::detail'
Investigation of file_lock.hpp reveals that:
- Indeed, both timed_acquire_file_lock and timed_acquire_file_lock_sharable are defined twice in their entirety
- Various functions calls are to functions in incorrect namespaces;
- try_acquire_file_lock, for example, is I believe in boost::interprocess::detail, which is not in scope (only boost::detail is).
- I'm not sure what scope sleep is supposed to be in.. there are a few implementations peppered throughout Boost
I'm not sure if other compilers perhaps have different scoping semantics and/or different ways of handling function redefinitions, but this definitely doesn't seem to fly on MSVC8.
A simple reproduction case:
#include <boost/interprocess/sync/file_lock.hpp> int main(int argc, char** argv) { printf("hello world"); return 0; }
Really only the inclusion of the header file is necessary, as stated earlier.
Thanks!
I also note that, of the duplicated functions, the first set uses winapi::sched_yield() to relinquish its timeslice, whereas the second set uses sleep(0) to do the same.
I'm not sure which is meant to be correct, as winapi::sched_yield() looks non-portable, while sleep() is a function that is not in scope.