boostorg / log

Boost Logging library
https://www.boost.org/libs/log/
182 stars 105 forks source link

Optional std::filesystem #191

Open Nekto89 opened 2 years ago

Nekto89 commented 2 years ago

It would be nice if there would be some magic option that will allow to build boost::log with std::filesystem instead of boost::filesystem. This will help with symbol problems in static configuration caused by BOOST_FILESYSTEM_VERSION define.

Lastique commented 2 years ago

Could you describe what kind of problems?

Nekto89 commented 2 years ago

Some public methods in boost::filesystem are marked as inline and have different implementation depending on BOOST_FILESYSTEM_VERSION. From Microsoft documentation: "The compiler treats the inline expansion options and keywords as suggestions. There's no guarantee that functions will be inlined. You can't force the compiler to inline a particular function, even with the __forceinline keyword. "

In some rare cases these simple one-liners aren't being inlined. So if boost is used as static library (users of shared libraries are safe :)), it might lead to situations when wrong version of method is linked in final binary. For example, if libboost_filesystem.lib has this "inlined" method with v4 and user's code (.obj/.lib files) expects that v3 will be called.

I've already replaced all boost::filesystem usages from my code, only transitive boost::process and boost::log are left. boost::process will have "BOOST_PROCESS_USE_STD_FS" in next version. It would be nice if it would be possible to have similar define in boost::log.