gulrak / filesystem

An implementation of C++17 std::filesystem for C++11 /C++14/C++17/C++20 on Windows, macOS, Linux and FreeBSD.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cannot include header in multiple place.

nukes opened this issue · comments

Describe the bug
As the implementation and declaration stays in one file, i can not include this file in different source files
if these files would be linked together. Because multiple definition exist in object files.

You may separate the implementation into .cc file ?

I see, you use inline for keep this header work in multiple files. But i find some methods are still not inline,which makes the problem.
I can successfully compile by fix the methods by add "inline" keyword, but i think it is not a good solution as the code size grows a lot in my case.
I think a separate the implementation into .cc file is still a good idea.

Indeed some inlines where missing. I missed adding a test to ensure that including it into multiple implementation files works. I'll push a fix for that.

I understand, that there are arguments for a separated approach, but this is explicitly designed as a header-only/single-file solution, so currently there are no plans for separation into a .h/.cpp pair of files or even more files.

I once had an early version that supported separation by including the header with specific defines for implementation or forwarding header, but the effect was not as relevant as I had hoped, the code got quite a bit uglier to work with, and with link-time-optimization (-flto on gcc) most redundancies are dropped from the binary.
Still if multiple shared libraries are including this header, it might make more of a difference, but the results of that tests pushed the feature down the list.