Fix compilation warnings and missing includes#190
Conversation
Added missing standard and ICU headers, removed unused variables, and added template deduction guides for C++20 compatibility.
|
This code already requires C++20 according to here: https://github.com/unicode-org/inflection/blob/main/inflection/CMakeLists.txt#L35 The code is definitely biased towards clang. I believe that I got the code to run on Linux with g++ once I removed the Core Foundation dependency. Either it's a different version of clang, or something beyond the typical clang++/g++, or another platform beyond the typical Linux. The header issues are odd, but we can make those changes. I'm not a fan of the template changes. Can you provide the actual warning? The call site should probably be changed so that the issue doesn't appear. |
| catch (const std::bad_alloc&) { | ||
| // Oh well, delete it below | ||
| e.what(); | ||
| } |
There was a problem hiding this comment.
This was meant to address a different warning about not handling such issues, but whatever. The behavior of ignoring the rare exception is intentional.
The compiler (Clang) emitted -Wctad-maybe-unsupported warnings because Class Template Argument Deduction (CTAD) was used without explicit deduction guides or because the compiler wasn't sure if deduction was intended. Let's change the call sites. |
grhoten
left a comment
There was a problem hiding this comment.
The changes look good. Do you have more information about the compiler or options used? Perhaps it can be added to the GitHub configurations to test so that this doesn't regress.
This PR addresses several compilation warnings and missing includes encountered when building with stricter compilers and newer C++ standards (like C++20).
Changes included:
Missing standard headers: Added for getenv and llabs in ResourceLocator.cpp and NumberConcept.cpp.
Missing ICU headers: Added utf16.h, uchar.h, and utf8.h in files using ICU macros without explicit includes (NumberCleaverIterator.cpp, StringUtils.cpp, StringViewUtils.cpp).
Compiler Warning Fix: Removed an unused variable in ICUTokenExtractorIterator.cpp that triggered a nodiscard warning.
C++20 Compatibility: Added template deduction guides for CompressedArray and MarisaTrie in their respective headers to resolve warnings about class template argument deduction.
These changes help in making the codebase compatible with a wider range of compilers and standards.
All tests passed locally.