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)
Change History (4)
comment:1 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 12 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
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 , 12 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
by , 10 years ago
Attachment: | config.hpp added |
---|
Note:
See TracTickets
for help on using tickets.
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