Meta/CMake: Fix non-obvious environ-related error in Wasi.cpp

environ in
`ErrorOr<Result<void>> Implementation::impl$environ_get(Configuration&
configuration, Pointer<Pointer<u8>> environ, Pointer<u8> environ_buf)`
is expanded to `(*__p__environ())`, which changes the type of the
second parameter to `Pointer<Pointer<u8>>* (*)()`

I spent several hours debugging this.

Error:

Libraries\LibWasm/Wasi.h(48,41): error : field has incomplete type
'typename ToCompatibleValue<DistinctNumeric<LittleEndian<unsigned
int>, __Pointer_tag<DistinctNumeric<LittleEndian<unsigned int>,
__Pointer_tag<unsigned char>, Comparison>>, Comparison> *(*)()>::Type'
(aka 'void')

Libraries\LibWasm\WASI\Wasi.cpp(1042,53): message : in instantiation of
template class 'Wasm::Wasi::ABI::CompatibleValue<AK::DistinctNumeric
<Wasm::Wasi::LittleEndian<unsigned int>, Wasm::Wasi::Detail::
__Pointer_tag<AK::DistinctNumeric<Wasm::Wasi::LittleEndian<unsigned
int>, Wasm::Wasi::Detail::__Pointer_tag<unsigned char>,
AK::DistinctNumericFeature::Comparison>>,
AK::DistinctNumericFeature::Comparison> *(*)()>' requested here

(... 11 more lines of errors)
This commit is contained in:
stasoid 2024-12-19 15:42:36 +05:00
parent 15a96e841b
commit 051447c0c0
2 changed files with 4 additions and 1 deletions

View file

@ -23,6 +23,8 @@ char** raw_environ()
{
#if defined(AK_OS_MACOS) || defined(AK_OS_IOS)
return *_NSGetEnviron();
#elif defined AK_OS_WINDOWS
return *__p__environ();
#else
return environ;
#endif
@ -178,7 +180,7 @@ ErrorOr<void> clear()
}
#elif defined(AK_OS_WINDOWS)
// environ = 0 doesn't work on Windows
while (auto str = environ[0]) {
while (auto str = raw_environ()[0]) {
auto eq = strchr(str, '=');
VERIFY(eq);
size_t name_len = eq - str;

View file

@ -45,6 +45,7 @@ if (WIN32)
add_compile_options(-Wno-microsoft-unqualified-friend) # MSVC doesn't support unqualified friends
add_compile_definitions(_CRT_SECURE_NO_WARNINGS) # _s replacements not desired (or implemented on any other platform other than VxWorks)
add_compile_definitions(_CRT_NONSTDC_NO_WARNINGS) # POSIX names are just fine, thanks
add_compile_definitions(_CRT_BEST_PRACTICES_USAGE) # don't #define _environ (*__p__environ())
add_compile_definitions(_USE_MATH_DEFINES)
add_compile_definitions(NOMINMAX)
add_compile_definitions(WIN32_LEAN_AND_MEAN)