Opened 12 years ago

Closed 12 years ago

#4891 closed Feature Requests (fixed)

include config/user.hpp in filesystem/* headers

Reported by: Andrey Semashev Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.45.0 Severity: Problem
Keywords: Cc:

Description

It would be convenient to be able to define default Boost.Filesystem version by defining BOOST_FILESYSTEM_VERSION macro in the boost/config/user.hpp header. In order that to work, dispatching headers in boost/filesystem should include boost/config/user.hpp (or boost/config.hpp) before testing the macro and deciding which library version to use.

Attachments (1)

config.hpp (3.8 KB ) - added by anonymous 10 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 by Beman Dawes, 12 years ago

Resolution: fixed
Status: newclosed

All Boost.Filesystem headers already first include <boost/config.hpp> directly or indirectly. That isn't obvious, particularly for V2, so I added some initial V2 includes to make it more obvious.

The documentation has also been changed to add <boost/config/user.hpp> to the list of places where BOOST_FILESYSTEM_VERSION can be defined.

Thanks,

--Beman

comment:2 by Andrey Semashev, 12 years ago

Resolution: fixed
Status: closedreopened

No, it doesn't work, because headers directly beneath filesystem directory don't include config.hpp. Assuming I have #defined BOOST_FILESYSTEM_VERSION 2 in my user.hpp, compiling this code fails:

#include <boost/filesystem/path.hpp>

template< typename T1, typename T2 >
void with_path(boost::filesystem::basic_path< T1, T2 >)
{
}


int main(int, char*[])
{
    with_path(boost::filesystem::path());
    return 0;
}

The error is as follows:

In file included from ./boost/config.hpp:26,
                 from ./boost/filesystem/v3/path.hpp:18,
                 from ./boost/filesystem/path.hpp:28,
                 from fs_test.cpp:1:
./boost/config/user.hpp:123: warning: "BOOST_FILESYSTEM_VERSION" redefined
./boost/filesystem/path.hpp:21: note: this is the location of the previous definition
In file included from ./boost/filesystem/v3/path.hpp:24,
                 from ./boost/filesystem/path.hpp:28,
                 from fs_test.cpp:1:
./boost/filesystem/v3/config.hpp:16: error: #error Compiling Filesystem version 3 file with BOOST_FILESYSTEM_VERSION defined != 3
fs_test.cpp:4: error: variable or field ‘with_path’ declared void
fs_test.cpp:4: error: ‘basic_path’ is not a member of ‘boost::filesystem’
fs_test.cpp:4: error: expected primary-expression before ‘,’ token
fs_test.cpp:4: error: expected primary-expression before ‘>’ token
fs_test.cpp:4: error: expected primary-expression before ‘)’ token
fs_test.cpp: In function ‘int main(int, char**)’:
fs_test.cpp:11: error: ‘with_path’ was not declared in this scope

comment:3 by Beman Dawes, 12 years ago

Resolution: fixed
Status: reopenedclosed

(In [67066]) Fix #4891, again, clearing problem if BOOST_FILESYSTEM_VERSION defined in <boost/config/user.hpp>

by anonymous, 10 years ago

Attachment: config.hpp added
Note: See TracTickets for help on using tickets.