On Friday 05 June 2015 17:05:08 Edward Diener wrote:
On 6/5/2015 3:37 PM, Andrey Semashev wrote:
1. What if the Boost version requires linking with a built library? These headers won't be able to hide that.
You are correct. But what are the issues about linking to a Boost library which needs to be addressed as you see it ?
Notice that anything necessary to linking to a Boost library can be figured out macro-wise for a given library by first currently testing BOOST_CPP_HAS_XXX for 0 to determine that it is the Boost library which will be used. Of course some other BOOST_CPP_XXX macro would need to be added to specify whether the Boost library needs to be linked or not. So if there is anything which could be automated as part of the source code to automate linking I should be able to automatically configure it using macros also. As an expansion of the basic set of macros which are offered for each library, if the solution to linking is a generic solution I do not mind adding it in. But let's first identify the problem before we can identify any possible generic solution.
In general, you won't get away with just macros, as autolinking is only present in MSVC & friends. This would also affect build system scripts. Suppose I'm a (Boost) library writer; the library has a compiled part and I'm writing a Makefile/Jamfile. If I'm using these macros, I still have to know when to link and when not to link with Boost libs. This can be rather tricky as not only compiler versions should be checked but also their options; and it also needs to be in sync with Boost.Config. The same happens when I'm a user of a (Boost) library that uses these macros, only it becomes more difficult to be in sync with Boost.Config. My point is that since these macros don't actually abstract me away from the configuration, why would I use them? Arguably, this problem goes away if the macros only handle components which are header-only in Boost.
2. I'm worried if these tools will be used in Boost libraries in a way that affects library API/ABI. What if one library uses these tools and the other doesn't - will these libraries be able to interoperate? Or is it a user's problem? There is also the possibility that Boost is built in C++03 mode and the user builds his code in C++11. I think this will be most apparent with utilities like shared_ptr and function, which are often present in the interfaces.
Its no different from some Boost library using the C++ standard version of, let's say, std::function because it is available and another library using boost::function. Is API/ABI compatibility affected ? If so that has to be taken into account if you use those libraries internally. Suppose library X is compiled using C++11 mode and your own library Y, which uses library X as a dependency, is compiled without C++11 mode.
It's more likely that Boost is compiled in one mode and distributed in a standard package (say, with a Linux distro) and I'm building my app locally with that Boost. Most Linux distros build Boost with default compiler options which means C++03. If these macros affect Boost libraries ABI I will no longer be able to build my app in C++11 mode.
Again those factors of interoperability between the libraries must be taken into account. Using my macros is not going to change any of that, and my macro system cannot solve that problem, or make it more or less than if the macro system I propose were not used at all.
As Peter noted, having these macros in Boost.Config can be seen as encouragement to use. And when used improperly they can cause real problems. So far I'm seeing these macros only applicable under the following conditions: a) the macros can be used in header-only libraries or concealed in the compiled part of the library without exposing it to API/ABI, and b) only when these macros allow to switch between STL and header-only Boost alternatives (not compiled ones). I'm not sure how to enforce these restrictions and I'm not sure adding them without doing something about their dangerous use is a good idea. Sorry if I'm not being helpful here.