supercollider / supercollider

An audio server, programming language, and IDE for sound synthesis and algorithmic composition.
http://supercollider.github.io
GNU General Public License v3.0
5.53k stars 754 forks source link

fix `incompatible-pointer-types` warnings #6435

Closed Spacechild1 closed 47 minutes ago

Spacechild1 commented 2 months ago

Environment

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 |
capital-G commented 2 months ago

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.

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 :)

xunil-cloud commented 1 month ago

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.

xunil-cloud commented 1 week ago

I made a PR in hidapi repo to fix incompatible-pointer-types warnings , maybe someone can take a look?