Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2003-12-17 13:21:10


David Abrahams wrote:
>
>Beman Dawes <bdawes_at_[hidden]> writes:
>
> > At 06:23 AM 12/17/2003, Bronek Kozicki wrote:
> >
> > >I have two errors while building boost on MSVC71 (toolset vc7.1).
> > >Apparently boost::filesystem::directory_iterator should have member
> > >functions "decrement" and "advance", but these functions do not exist,
> > >at least on my platform.
> >
> > It is more complicated than
> > that. boost::filesystem::directory_iterator is an input iterator. It
> > is specified like this:
> >
> > class BOOST_FILESYSTEM_DECL directory_iterator
> > : public boost::iterator_facade<
> > directory_iterator,
> > path,
> > boost::single_pass_traversal_tag >
> >
> > Perhaps I've got that wrong, but it has worked since the new-style
> > iterator_facade was introduced, and it still compiles fine and passes
> > all tests when built as a static library. See today's regression
> > tests.
> >
> > The problem arises only when it is built as a Windows DLL.
> >
> > I could use some help on this. I don't understand why building as a
> > DLL causes boost::iterator_facade to instantiate differently. Is the
> > BOOST_FILESYSTEM_DECL the problem, and if so, what is the fix?
>
>IIUC Exporting a class template in a DLL instantiates all of its
>non-template member functions, so yes, that's the problem.

I have created a simple DLL program in my own project/makefile system (not
Boost.Build) that compiles the file:

// test.cpp:
#include <libs/filesystem/src/operations_posix_windows.cpp> // latest CVS
version

using the command line:

   d:/devel\VS.NET\vc71\bin\cl
      -DSTRICT -D_WIN32_IE=0x0500 -DWINVER=0x0500 -D_X86_=1 -DWIN32 -D_WIN32
      -D_WINNT -D_WIN32_WINNT=0x0500 -DUNICODE
      -c -nologo -Zc:forScope -Zc:wchar_t -W4 -X
      -I"d:/devel\VS.NET\vc71\include" -I"d:/devel\VS.NET\vc71\crt\include"
      -I"d:/devel\PlatformSDK\200210\include"
-I"d:/devel\PlatformSDK\DX9\include"
      -I"d:/devel\.NET\include" -I"d:/devel\ADL++\include"
      -I"d:/devel\libraries\boost\boost"
-I"d:/devel\libraries\boost\boost-sandbox"
      -GX test.cpp

and did not get the errors that have been reported. This should have
generated the error if it were that the problematic functions
(boost::iterator_core_access::increment, etc.) were being instantiated due
to the __declspec(dllexport) class qualification. It therefore leads me to
believe that either:

[1] There is a problem with Boost.Build (unlikely).

[2] That directory_iterator::operator++() is being accessed elsewhere during
the library build. But this does not make sense, as it would appear in the
static build as well. Is there a different command-line for the compiler
when doing a static and a DLL build? Is one of these producing the error?

[3] All of iterator_facade is being instantiated in the DLL as suggested by
Dave Abrahams.

>There are a few possible fixes:
>
> 1. stop exporting it; make everything inline (you can dispatch to
> exported implementation functions).

How would this work? Surely you would still have the same problem, or am I
missing something?

> 2. provide dummy advance and decrement functions

This would prevent the compiler throwing errors when trying to apply
non-InputIterator operations on directory_iterator.

>I'm sure there are a few others, but those are the ones that are
>obvious to me. I prefer #1 because it prevents misuse from compiling.

Regards,
Reece H Dunn

_________________________________________________________________
Use MSN Messenger to send music and pics to your friends
http://www.msn.co.uk/messenger


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk