Skip to content

C99 compile - static_assert failure #764

Closed

Description

@cscd98

With C standard of C99 static_assert is no longer available causing a compile failure:

static_assert(sizeof(struct hid_pp_link_collection_node_) == 16,

Activity

  1. added
    Windows
    on Dec 20, 2025
  2. mcuee commented on Dec 20, 2025

    @mcuee
    Member

    What is the compiler used to trigger this issue?

    Take note we only support MSYS2 GCC/clang and MSVC under Windows.

  3. cscd98 commented on Dec 20, 2025

    @cscd98
    Author

    Hi, it would had been the latest msys2 release on Windows.

  4. mcuee commented on Dec 20, 2025

    @mcuee
    Member

    I just tried latest MSYS2 mingw64 toolchain under Windows 11 and there is no issue to build latest hidapi git.

    MINGW64 /c/work/libusb/hidapi
    $ gcc -v
    Using built-in specs.
    COLLECT_GCC=C:\msys64\mingw64\bin\gcc.exe
    COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/lto-wrapper.exe
    Target: x86_64-w64-mingw32
    Configured with: ../gcc-15.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --with-native-system-header-dir=/mingw64/include --libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --with-tune=generic --enable-mingw-wildcard --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-backtrace=yes --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-libssp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev8, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --with-libstdcxx-zoneinfo=yes --disable-libstdcxx-debug --enable-plugin --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
    Thread model: posix
    Supported LTO compression algorithms: zlib zstd
    gcc version 15.2.0 (Rev8, Built by MSYS2 project)
    
    $ cat build_cmake_mingw64_1.sh
    cmake -B buildmingw64 -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_PP_DATA_DUMP=ON -DCMAKE_INSTALL_PREFIX=buildmingw64 -DHIDAPI_BUILD_HIDTEST=ON
    cmake --build buildmingw64 --target install
    
    $ sh build_cmake_mingw64_1.sh
    -- Building for: Ninja
    -- The C compiler identification is GNU 15.2.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- hidapi: v0.16.0
    -- Building hidtest
    -- Configuring done (0.8s)
    -- Generating done (0.0s)
    -- Build files have been written to: C:/work/libusb/hidapi/buildmingw64
    [10/11] Install the project...-- Install configuration: "RelWithDebInfo"
    -- Installing: C:/work/libusb/hidapi/buildmingw64/lib/libhidapi.dll.a
    -- Installing: C:/work/libusb/hidapi/buildmingw64/bin/libhidapi.dll
    -- Installing: C:/work/libusb/hidapi/buildmingw64/include/hidapi/hidapi.h
    -- Installing: C:/work/libusb/hidapi/buildmingw64/include/hidapi/hidapi_winapi.h
    -- Installing: C:/work/libusb/hidapi/buildmingw64/lib/pkgconfig/hidapi.pc
    -- Installing: C:/work/libusb/hidapi/buildmingw64/bin/pp_data_dump.exe
    -- Installing: C:/work/libusb/hidapi/buildmingw64/lib/cmake/hidapi/libhidapi.cmake
    -- Installing: C:/work/libusb/hidapi/buildmingw64/lib/cmake/hidapi/libhidapi-relwithdebinfo.cmake
    -- Installing: C:/work/libusb/hidapi/buildmingw64/lib/cmake/hidapi/hidapi-config-version.cmake
    -- Installing: C:/work/libusb/hidapi/buildmingw64/lib/cmake/hidapi/hidapi-config.cmake
    -- Installing: C:/work/libusb/hidapi/buildmingw64/bin/hidtest.exe
    
  5. cscd98 commented on Dec 20, 2025

    @cscd98
    Author

    It only occurs when setting the c standard to 99.

    set(CMAKE_C_STANDARD 99)

  6. Youw commented on Dec 20, 2025

    @Youw
    Member

    If this is the only breaking code for C11, I guess we could have a condition on C standard for the compilation.
    But I'd like to know what forces you to use C99 to compile HIDAPI?

  7. added a commit that references this issue on May 20, 2026
    5bec589
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Windows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions