Using zig c++ to compile a C++ file, how to suppress _Nonnull warnings?

I am using zig c++ to compile a C++ file that links against GMP. I keep getting this warning from GMP headers:

warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]

The code compiles and runs fine. I just want to hide these warnings.
Is there a way to do this with zig c++ flags?

try adding the -Wno-nullability-completeness flag

I also tried -w to silence all warnings but the warnings still show up, I’m not sure if this is a bug or not.

They seem to be coming from zig’s own files, not from GMP:

.../zig/0.16.0/lib/libcxx/include/string:3884:75: warning: pointer is
      missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
 3884 | _LIBCPP_EXPORTED_FROM_ABI unsigned long stoul(const wstring& __str, size_t* __idx = nullptr, int __base = 10);

This will be fixed in 0.17.0: https://codeberg.org/ziglang/zig/pulls/31868

5 Likes