Russ Wood wrote:
Hi,
When using the filesystem lib in the 1.30.0 release, I experience hangs when incrementing the directory iterator.
The compiler I've been using is MinGW, an example that exhibits the behaviour on my machine is included below.
The hang only occurs when -mthreads is used.
The hang occurs on the increment when there are no more files in the directory.
I had the same problem with C++Builder 6 when first using the filesystem library. The default builds for filesystem are single threaded. If your application is multi-threaded, then you need to re-build the filesystem library with multi-threading (it uses mutexes somewhere (I think from smart_ptr but can't remember)). If you use the single-threaded library, then you don't get the mutex, but the ++operator is inlined and tries to lock it. This causes a hang as the win32 light-weight mutex is stored as just an integer (long maybe), so the program just hangs waiting for it to be cleared. I have built four versions of the library libboost_filesystem.lib - release, single-threaded libboost_filesystemd.lib - debug, single-threaded libboost_filesystemmt.lib - release, multi-threaded libboost_filesystemmtd.lib - debug, multi-threaded I use a #pragma int the code to link the appropriate lib depending on Borland's __MT__ define (and also if I want debugging or not) HTH Russell