fix `incompatible-pointer-types` warnings
Environment
- SuperCollider version: latest develop (31a4bc07a16311a5ae28fd1f233167a822b048b3)
- Operating system: Windows, Msys2
- Other details (Qt version, audio driver, etc.): compiler GCC 14.1.0 (Msys2)
GCC 14 has upgraded the -Wincompatible-pointer-types warning to an error. As a consequence, some (external) C code in SC fails to compile, namely portmidi and hidapi:
C:/Repos/supercollider/external_libraries/portmidi/pm_win/pmwinmm.c:1052:31: error: assignment to 'uint32_
t *' {aka 'unsigned int *'} from incompatible pointer type 'DWORD *' {aka 'long unsigned int *'} [-Wincomp
atible-pointer-types]
1052 | midi->fill_offset_ptr = &(hdr->dwBytesRecorded);
| ^
C:/Repos/supercollider/external_libraries/hidapi/hidapi_parser/hidapi_parser.c: In function 'hid_parse_ele
ment_info':
C:/Repos/supercollider/external_libraries/hidapi/hidapi_parser/hidapi_parser.c:1630:64: error: passing arg
ument 2 of 'HidP_GetLinkCollectionNodes' from incompatible pointer type [-Wincompatible-pointer-types]
1630 | nt_res = HidP_GetLinkCollectionNodes( linkCollectionNodes, &numColls, pp_data );
| ^~~~~~~~~
| |
| int *
As a temporary fix we might pass -Wno-error=incompatible-pointer-types so that we still get the warning, but it's not treated as an error. Ideally, the issue should be fixed upstream.
Also, there is another compilation error in SC_PAUtiles because of a missing include of <cstdint>:
C:/Repos/supercollider/common/SC_PaUtils.cpp: In function 'PaError TryGetDefaultPaDevices(PaDeviceIndex*,
PaDeviceIndex*, int, int, double)':
C:/Repos/supercollider/common/SC_PaUtils.cpp:130:21: error: 'uint32_t' was not declared in this scope
130 | if (uint32_t(inSR) != uint32_t(outSR)) {
| ^~~~~~~~
C:/Repos/supercollider/common/SC_PaUtils.cpp:6:1: note: 'uint32_t' is defined in header '<cstdint>'; this
is probably fixable by adding '#include <cstdint>'
5 | #include <cstdio>
+++ |+#include <cstdint>
6 |
Quoting from my reply in #6436
In general, I'd prefer to do it "properly" by fixing our dependencies if it's not too much work for now.
- It seems our portmidi dependency hasn't been updated since 9 years - maybe we should update it as it's still maintained, see https://github.com/PortMidi/portmidi ? while we're at it, maybe we can make it a git submodule instead of copying files around to keep our history/repo a bit cleaner?
- Can you estimate how much effort it would take to fix hidapi? IIUC it is a fork maintained by SC, so we could quickly in-cooperate any PRs.
Additionally, if we decide to go with the fix, we should add gcc14 to our linux build pipeline (maybe replacing gcc7/gcc9?). If you need help with this, I can help. We should also update our README. Maybe @dyfer can also provide some input here, as we recently talked about upgrading the versions used in our CI, see https://github.com/supercollider/supercollider/issues/6430
Edit: https://github.com/supercollider/supercollider/pull/6436 implements a temporary™ fix :)
Actually, I think this doesn't impact Linux, because these code are only used on Windows. It seems that portmidi is only used on Windows (correct me if I'm wrong) and HidP_GetLinkCollectionNodes is a Windows API function.
I made a PR in hidapi repo to fix incompatible-pointer-types warnings , maybe someone can take a look?
As this is fixed, I'll unpin this issue, I hope that's okay.