gulrak / filesystem

An implementation of C++17 std::filesystem for C++11 /C++14/C++17/C++20 on Windows, macOS, Linux and FreeBSD.
MIT License
1.32k stars 168 forks source link

Compile-Errors with gcc 4.7.2 #184

Closed mihovilkolaric closed 3 weeks ago

mihovilkolaric commented 3 weeks ago

Describe the bug I am trying to use this project to compile a project using C++20 on an embedded hardware that uses an old GCC version. (g++ -v identifies it identifies as gcc version 4.7.2 (Ingenic r2.3.3 2016.12))

The compiler/toolchain is from: https://github.com/Dafang-Hacks/mips-gcc472-glibc216-64bit

The project I am trying to "backport" for my camera is: https://github.com/gtxaspec/prudynt-t/

To Reproduce I downloaded gulrak/filesystem and copied it in the src-folder of prudynt-t, and included it as described in https://github.com/gulrak/filesystem?tab=readme-ov-file#using-it-as-single-file-header

make fails with following errors:

In file included from src/Config.cpp:44:0:
src/filesystem.hpp:657:24: error: looser throw specifier for 'virtual ghc::filesystem::filesystem_error::~filesystem_error()'
In file included from /home/test/camera_hack/prudynt/prudynt-cross/mips-gcc472-glibc216-64bit/bin/../lib/gcc/mips-linux-gnu/4.7.2/../../../../mips-linux-gnu/include/c++/4.7.2/mutex:44:0,
                 from src/Logger.hpp:6,
                 from src/Config.cpp:12:
/home/test/camera_hack/prudynt/prudynt-cross/mips-gcc472-glibc216-64bit/bin/../lib/gcc/mips-linux-gnu/4.7.2/../../../../mips-linux-gnu/include/c++/4.7.2/system_error:340:13: error:   overriding 'virtual std::system_error::~system_error() noexcept (true)'
In file included from src/Config.cpp:44:0:
src/filesystem.hpp:919:44: error: expected ';' at end of member declaration
src/filesystem.hpp:919:51: error: expected unqualified-id before 'noexcept'
src/filesystem.hpp:919:49: error: expected ';' at end of member declaration
src/filesystem.hpp:919:51: error: expected unqualified-id before 'noexcept'
src/filesystem.hpp:920:35: error: expected ';' at end of member declaration
src/filesystem.hpp:920:40: error: expected unqualified-id before 'noexcept'
src/filesystem.hpp:920:37: error: expected ';' at end of member declaration
src/filesystem.hpp:920:40: error: expected unqualified-id before 'noexcept'

Note: In order to omit other compiler-errors of prudynt-t, I added following compiler-options: -std=c++11 as well as -D_GLIBCXX_USE_NANOSLEEP -D_GLIBCXX_USE_SCHED_YIELD

Is it supposed to work with that compiler? As the compiler claims to support C++11 I expected it to work.

Expected behavior It compiles ;-)

gulrak commented 3 weeks ago

I'm sorry, but sadly gcc 4.7 version line is not fully C++11 compatible, the official wording is experimental support for the 2011 ISO C++ standard, and from my own experience in other projects there is quite some to be desired for it to be a fully C++11 conforming compiler. As I don't have any means of testing it and do not want to go below actual C++11 I don't plan on adding support for early attempts on C++11, as then I would have to have it as CI pipeline to ensure it stays compatible. So TLDR: I'm not supporting anything below GCC 5 from my side and I didn't even try any GCC below 5.5, but would think other 5.x should work.

I'm not saying I am totally against someone putting in the work but my willingness to accept any PR supporting any 4.x variant of gcc really depends on the amount of code changed and the ease of it being automatically checked in a workflow, so if it changes code and/or style too much for my taste one might end up having to support that in a fork.

gulrak commented 3 weeks ago

To add to this, as I had a bit of time to look into it, it seems a part of this is related to a bug in GCC 4.7, that it doesn't conform to the C++11 rule of implicit noexcept(true) on destructors.

mihovilkolaric commented 3 weeks ago

Hi, thanks for the fast analysis and response - I already expected that 4.7.2 is way to old to be supported.