pywinrt / python-winsdk

Python package with bindings for Windows SDK
https://python-winsdk.readthedocs.io
MIT License
77 stars 8 forks source link

More Clang and GCC build errors #33

Closed mimi89999 closed 1 year ago

mimi89999 commented 1 year ago

Hello, I noticed that if I don't precompile the headers (remove this line: https://github.com/pywinrt/python-winsdk/blob/main/CMakeLists.txt#L33), the build will fail with the following errors:

[1/319] Building CXX object CMakeFiles/_winrt.dir/pywinrt/winsdk/src/_winrt_array.cpp.obj
FAILED: CMakeFiles/_winrt.dir/pywinrt/winsdk/src/_winrt_array.cpp.obj
C:\msys64\clang64\bin\c++.exe -D_winrt_EXPORTS -IC:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/cppwinrt -IC:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src -isystem C:/msys64/clang64/include/python3.10 -march=nocona -msahf -mtune=generic -O2 -pipe -O3 -DNDEBUG -std=gnu++20 -MD -MT CMakeFiles/_winrt.dir/pywinrt/winsdk/src/_winrt_array.cpp.obj -MF CMakeFiles\_winrt.dir\pywinrt\winsdk\src\_winrt_array.cpp.obj.d -o CMakeFiles/_winrt.dir/pywinrt/winsdk/src/_winrt_array.cpp.obj -c C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/_winrt_array.cpp
In file included from C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/_winrt_array.cpp:3:
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/pybase.h:32:22: warning: implicit conversion of nullptr constant to 'bool' [-Wnull-conversion]
            return T{nullptr};
                    ~^~~~~~~
                     false
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/pybase.h:2112:70: note: in instantiation of member function 'py::empty_instance<bool>::get' requested here
                array = winrt::com_array<T>(size, empty_instance<T>::get());
                                                                     ^
C:/msys64/clang64/include/c++/v1/__memory/unique_ptr.h:714:32: note: in instantiation of member function 'py::ComArray<bool>::Alloc' requested here
    return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
                               ^
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/_winrt_array.cpp:114:36: note: in instantiation of function template specialization 'std::make_unique<py::ComArray<bool>>' requested here
                self->array = std::make_unique<py::ComArray<bool>>();
                                   ^
In file included from C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/_winrt_array.cpp:3:
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/pybase.h:2129:13: error: static assertion failed due to requirement 'buffer_format<winrt::Windows::Foundation::Point>'
            static_assert(buffer_format<T>);
            ^             ~~~~~~~~~~~~~~~~
C:/msys64/clang64/include/c++/v1/__memory/unique_ptr.h:714:32: note: in instantiation of member function 'py::ComArray<winrt::Windows::Foundation::Point>::Format' requested here
    return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
                               ^
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/_winrt_array.cpp:220:36: note: in instantiation of function template specialization 'std::make_unique<py::ComArray<winrt::Windows::Foundation::Point>>' requested here
                self->array = std::make_unique<
                                   ^
In file included from C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/_winrt_array.cpp:3:
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/pybase.h:2129:13: error: static assertion failed due to requirement 'buffer_format<winrt::Windows::Foundation::Size>'
            static_assert(buffer_format<T>);
            ^             ~~~~~~~~~~~~~~~~
C:/msys64/clang64/include/c++/v1/__memory/unique_ptr.h:714:32: note: in instantiation of member function 'py::ComArray<winrt::Windows::Foundation::Size>::Format' requested here
    return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
                               ^
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/_winrt_array.cpp:225:36: note: in instantiation of function template specialization 'std::make_unique<py::ComArray<winrt::Windows::Foundation::Size>>' requested here
                self->array = std::make_unique<
                                   ^
In file included from C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/_winrt_array.cpp:3:
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/pybase.h:2129:13: error: static assertion failed due to requirement 'buffer_format<winrt::Windows::Foundation::Rect>'
            static_assert(buffer_format<T>);
            ^             ~~~~~~~~~~~~~~~~
C:/msys64/clang64/include/c++/v1/__memory/unique_ptr.h:714:32: note: in instantiation of member function 'py::ComArray<winrt::Windows::Foundation::Rect>::Format' requested here
    return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
                               ^
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/_winrt_array.cpp:230:36: note: in instantiation of function template specialization 'std::make_unique<py::ComArray<winrt::Windows::Foundation::Rect>>' requested here
                self->array = std::make_unique<
                                   ^
1 warning and 3 errors generated.
[9/319] Building CXX object CMakeFiles/_winrt.dir/pywinrt/winsdk/src/py.Windows.AI.MachineLearning.cpp.obj
In file included from C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/py.Windows.AI.MachineLearning.cpp:3:
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/pybase.h:32:22: warning: implicit conversion of nullptr constant to 'bool' [-Wnull-conversion]
            return T{nullptr};
                    ~^~~~~~~
                     false
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/py.Windows.Foundation.Collections.h:2100:70: note: in instantiation of member function 'py::empty_instance<bool>::get' requested here
                winrt::com_array<T> items(length, empty_instance<T>::get());
                                                                     ^
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/py.Windows.Foundation.Collections.h:1870:9: note: in instantiation of member function 'py::impl::Windows::Foundation::Collections::IVectorView<bool>::seq_subscript' requested here
        IVectorView(winrt::Windows::Foundation::Collections::IVectorView<T> o) : _obj(o) {}
        ^
C:/msys64/clang64/include/c++/v1/__memory/unique_ptr.h:714:32: note: in instantiation of member function 'py::impl::Windows::Foundation::Collections::IVectorView<bool>::IVectorView' requested here
    return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
                               ^
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/pybase.h:605:33: note: in instantiation of function template specialization 'std::make_unique<py::impl::Windows::Foundation::Collections::IVectorView<bool>, winrt::Windows::Foundation::Collections::IVectorView<bool> &>' requested here
        py_instance->obj = std::make_unique<typename ptype::concrete>(instance);
                                ^
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/pybase.h:647:24: note: in instantiation of function template specialization 'py::wrap_pinterface<winrt::Windows::Foundation::Collections::IVectorView<bool>>' requested here
                return wrap_pinterface<T>(instance);
                       ^
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/pybase.h:1696:20: note: in instantiation of function template specialization 'py::wrap<winrt::Windows::Foundation::Collections::IVectorView<bool>>' requested here
            return wrap(instance);
                   ^
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/pybase.h:1913:30: note: in instantiation of member function 'py::converter<winrt::Windows::Foundation::Collections::IVectorView<bool>>::convert' requested here
        return converter<T>::convert(instance);
                             ^
C:/Users/Michel/git/MINGW-packages/mingw-w64-python-winsdk/src/python-build-CLANG64/pywinrt/winsdk/src/py.Windows.AI.MachineLearning.cpp:3030:28: note: in instantiation of function template specialization 'py::convert<winrt::Windows::Foundation::Collections::IVectorView<bool>>' requested here
                return py::convert(self->obj.GetAsVectorView());
                           ^
1 warning generated.
dlech commented 1 year ago

I didn't see this exact error, but I noticed and fixed some other errors when compiling without PCH using MSVC.

mimi89999 commented 1 year ago

Thanks for fixing that! There is still the nullptr to bool conversion warning that is treated as an error due to -Werror

[1/319] Building CXX object CMakeFiles/_winrt.dir/pywinrt/winsdk/src/_winrt_array.cpp.obj
FAILED: CMakeFiles/_winrt.dir/pywinrt/winsdk/src/_winrt_array.cpp.obj
C:\msys64\clang64\bin\c++.exe -D_winrt_EXPORTS -IC:/Users/Michel/git/python-winsdk/cppwinrt -IC:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src -isystem C:/msys64/clang64/include/python3.10 -O3 -DNDEBUG -std=gnu++20 -Werror -MD -MT CMakeFiles/_winrt.dir/pywinrt/winsdk/src/_winrt_array.cpp.obj -MF CMakeFiles\_winrt.dir\pywinrt\winsdk\src\_winrt_array.cpp.obj.d -o CMakeFiles/_winrt.dir/pywinrt/winsdk/src/_winrt_array.cpp.obj -c C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/_winrt_array.cpp
In file included from C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/_winrt_array.cpp:3:
C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/pybase.h:32:22: error: implicit conversion of nullptr constant to 'bool' [-Werror,-Wnull-conversion]
            return T{nullptr};
                    ~^~~~~~~
                     false
C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/pybase.h:2112:70: note: in instantiation of member function 'py::empty_instance<bool>::get' requested here
                array = winrt::com_array<T>(size, empty_instance<T>::get());
                                                                     ^
C:/msys64/clang64/include/c++/v1/__memory/unique_ptr.h:714:32: note: in instantiation of member function 'py::ComArray<bool>::Alloc' requested here
    return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
                               ^
C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/_winrt_array.cpp:115:36: note: in instantiation of function template specialization 'std::make_unique<py::ComArray<bool>>' requested here
                self->array = std::make_unique<py::ComArray<bool>>();
                                   ^
1 error generated.
[5/319] Building CXX object CMakeFiles/_winrt.dir/pywinrt/winsdk/src/py.Windows.AI.MachineLearning.cpp.obj
FAILED: CMakeFiles/_winrt.dir/pywinrt/winsdk/src/py.Windows.AI.MachineLearning.cpp.obj
C:\msys64\clang64\bin\c++.exe -D_winrt_EXPORTS -IC:/Users/Michel/git/python-winsdk/cppwinrt -IC:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src -isystem C:/msys64/clang64/include/python3.10 -O3 -DNDEBUG -std=gnu++20 -Werror -MD -MT CMakeFiles/_winrt.dir/pywinrt/winsdk/src/py.Windows.AI.MachineLearning.cpp.obj -MF CMakeFiles\_winrt.dir\pywinrt\winsdk\src\py.Windows.AI.MachineLearning.cpp.obj.d -o CMakeFiles/_winrt.dir/pywinrt/winsdk/src/py.Windows.AI.MachineLearning.cpp.obj -c C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/py.Windows.AI.MachineLearning.cpp
In file included from C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/py.Windows.AI.MachineLearning.cpp:3:
C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/pybase.h:32:22: error: implicit conversion of nullptr constant to 'bool' [-Werror,-Wnull-conversion]
            return T{nullptr};
                    ~^~~~~~~
                     false
C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/py.Windows.Foundation.Collections.h:2102:70: note: in instantiation of member function 'py::empty_instance<bool>::get' requested here
                winrt::com_array<T> items(length, empty_instance<T>::get());
                                                                     ^
C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/py.Windows.Foundation.Collections.h:1872:9: note: in instantiation of member function 'py::impl::Windows::Foundation::Collections::IVectorView<bool>::seq_subscript' requested here
        IVectorView(winrt::Windows::Foundation::Collections::IVectorView<T> o) : _obj(o) {}
        ^
C:/msys64/clang64/include/c++/v1/__memory/unique_ptr.h:714:32: note: in instantiation of member function 'py::impl::Windows::Foundation::Collections::IVectorView<bool>::IVectorView' requested here
    return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
                               ^
C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/pybase.h:605:33: note: in instantiation of function template specialization 'std::make_unique<py::impl::Windows::Foundation::Collections::IVectorView<bool>, winrt::Windows::Foundation::Collections::IVectorView<bool> &>' requested here
        py_instance->obj = std::make_unique<typename ptype::concrete>(instance);
                                ^
C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/pybase.h:647:24: note: in instantiation of function template specialization 'py::wrap_pinterface<winrt::Windows::Foundation::Collections::IVectorView<bool>>' requested here
                return wrap_pinterface<T>(instance);
                       ^
C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/pybase.h:1696:20: note: in instantiation of function template specialization 'py::wrap<winrt::Windows::Foundation::Collections::IVectorView<bool>>' requested here
            return wrap(instance);
                   ^
C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/pybase.h:1913:30: note: in instantiation of member function 'py::converter<winrt::Windows::Foundation::Collections::IVectorView<bool>>::convert' requested here
        return converter<T>::convert(instance);
                             ^
C:/Users/Michel/git/python-winsdk/pywinrt/winsdk/src/py.Windows.AI.MachineLearning.cpp:3030:28: note: in instantiation of function template specialization 'py::convert<winrt::Windows::Foundation::Collections::IVectorView<bool>>' requested here
                return py::convert(self->obj.GetAsVectorView());
                           ^
1 error generated.
dlech commented 1 year ago

nullptr one should be fixed now too

dlech commented 1 year ago

If we want to make sure we don't break builds with other compilers in the future, it would be nice to add a ci job for it in the pywinrt repo, preferably using https://github.com/marketplace/actions/setup-msys2#build-matrix.

mimi89999 commented 1 year ago

Thanks for fixing this! I will look at the CI tomorrow.

dlech commented 1 year ago

I think all of the build issues are fixed now.