Modify

Ticket #4891 (closed Feature Requests: fixed)

Opened 3 years ago

Last modified 3 years ago

include config/user.hpp in filesystem/* headers

Reported by: andysem Owned by: bemandawes
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

config.hpp Download (3.8 KB) - added by anonymous 21 months ago.

Change History

comment:1 Changed 3 years ago by bemandawes

  • Status changed from new to closed
  • Resolution set to fixed

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 Changed 3 years ago by andysem

  • Status changed from closed to reopened
  • Resolution fixed deleted

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 Changed 3 years ago by bemandawes

  • Status changed from reopened to closed
  • Resolution set to fixed

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

Changed 21 months ago by anonymous

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.