Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::numeric_limitsが見つからない #917

Closed
hashitaku opened this issue Nov 22, 2022 · 3 comments
Closed

std::numeric_limitsが見つからない #917

hashitaku opened this issue Nov 22, 2022 · 3 comments

Comments

@hashitaku
Copy link
Member

エラーの内容 | Describe the build error

std::numeric_limitsが見つからないためコンパイルエラーになります。

In file included from /root/OpenSiv3D/Linux/../Siv3D/include/Siv3D/StringView.hpp:370,
                 from /root/OpenSiv3D/Linux/../Siv3D/include/Siv3D/String.hpp:19,
                 from /root/OpenSiv3D/Linux/../Siv3D/include/Siv3D/Error.hpp:14,
                 from /root/OpenSiv3D/Siv3D/src/Siv3D-Platform/Linux/Siv3D/Siv3DMain.cpp:15:
/root/OpenSiv3D/Linux/../Siv3D/include/Siv3D/detail/StringView.ipp: In member function ‘constexpr s3d::StringView::size_type s3d::StringView::max_size() const’:
/root/OpenSiv3D/Linux/../Siv3D/include/Siv3D/detail/StringView.ipp:119:56: error: incomplete type ‘std::numeric_limits<long unsigned int>’ used in nested name specifier
  119 |                 return std::numeric_limits<size_type>::max();
      |                                                        ^~~
make[2]: *** [CMakeFiles/Siv3D.dir/build.make:76: CMakeFiles/Siv3D.dir/root/OpenSiv3D/Siv3D/src/Siv3D-Platform/Linux/Siv3D/Siv3DMain.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/Siv3D.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

ビルド環境 | Develop environment (please complete the following information):

  • OS: Arch Linux
# gcc --version
gcc (GCC) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# g++ --version
g++ (GCC) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

備考 | Additional context

gcc-11からヘッダーファイルの依存関係が整理され一部のヘッダーファイルを明示的にインクルードする必要性があるようです。

https://gcc.gnu.org/gcc-11/porting_to.html

Header dependency changes
Some C++ Standard Library headers have been changed to no longer include other headers that were being used internally by the library. As such, C++ programs that used standard library components without including the right headers will no longer compile.
The following headers are used less widely in libstdc++ and may need to be included explicitly when compiled with GCC 11:

  • (for std::numeric_limits)
  • (for std::unique_ptr, std::shared_ptr etc.)
  • (for std::pair, std::tuple_size, std::index_sequence etc.)
  • (for members of namespace std::this_thread.)

wandboxで試したところgccのバージョンの違いでエラーになることが確認できました。

Siv3D/include/Siv3D/StringView.hppに以下の変更を加えることでコンパイルできるようになりました。

diff --git a/Siv3D/include/Siv3D/StringView.hpp b/Siv3D/include/Siv3D/StringView.hpp
index dfb4e5f..58005a4 100644
--- a/Siv3D/include/Siv3D/StringView.hpp
+++ b/Siv3D/include/Siv3D/StringView.hpp
@@ -19,6 +19,7 @@
 # include <cassert>
 # include <stdexcept>
 # include <algorithm>
+# include <limits>
 # include "Common.hpp"
 # include "Utility.hpp"
 # include "Hash.hpp"

自分の環境では完全にOpenSiv3dをビルドできていないのでエラー箇所がここのみか分かりませんが他にも明示的にインクルードしなければならない箇所があるかもしれません。

@Reputeless
Copy link
Member

ご報告ありがとうございます。
Arch Linux はテスト環境に入っていないため、ほかにも必要そうな追加のインクルードがあれば、まとめて v6_develop ブランチへ修正コミットを送っていただけると助かります。(上記 1 箇所でも ok です)

@hashitaku
Copy link
Member Author

debootstrap + systemd-nspawnで作ったubuntu-22.04環境(g++ Ubuntu 11.2.0-19ubuntu1 11.2.0)でビルドしてみた結果、エラーは上記の箇所のみだったので修正は一つで大丈夫だと思います。

関係ないのですが、上流 (Reputeless/Xoshiro-cpp@19bcbb2) で修正されていてmainブランチに反映されていない箇所でエラーになりました。

In file included from /root/OpenSiv3D/Siv3D/src/Siv3D/SFMT/SivSFMT.cpp:12:
/root/OpenSiv3D/Linux/../Siv3D/include/ThirdParty/Xoshiro-cpp/XoshiroCpp.hpp:73:27: error: ‘size_t’ hasnot been declared
   73 |                 template <size_t N>
      |

@Reputeless
Copy link
Member

確認ありがとうございます!
後者も含めて v6_develop ブランチへ pull request いただけますか。

Reputeless added a commit that referenced this issue Nov 23, 2022
Reputeless added a commit that referenced this issue Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants