acdemiralp / hid.hpp Goto Github PK
View Code? Open in Web Editor NEWSingle header C++23 wrapper for libusb/hidapi.
License: MIT License
Single header C++23 wrapper for libusb/hidapi.
License: MIT License
-Wno-changes-meaning option fixes errors below:
hid.hpp/include/hid/hid.hpp:42:17: error: declaration of ‘hid::bus_type hid::device_info::bus_type’ changes meaning of ‘bus_type’ [-Wchanges-meaning]
42 | bus_type bus_type;
| ^~~~~~~~
hid.hpp/include/hid/hid.hpp:42:3: note: used here to mean ‘enum class hid::bus_type’
42 | bus_type bus_type;
| ^~~~~~~~
hpp/include/hid/hid.hpp:21:12: note: declared here
21 | enum class bus_type
| ^~~~~~~~
hid.hpp/include/hid/hid.hpp:84:58: error: declaration of ‘std::expected<hid::device_info, std::__cxx11::basic_string<wchar_t> > hid::device::device_info() const’ changes meaning of ‘device_info’ [-Wchanges-meaning]
84 | std::expected<device_info, std::wstring> device_info () const
| ^~~~~~~~~~~
hid.hpp/include/hid/hid.hpp:84:17: note: used here to mean ‘struct hid::device_info’
84 | std::expected<device_info, std::wstring> device_info () const
| ^~~~~~~~~~~
hid.hpp/include/hid/hid.hpp:30:8: note: declared here
30 | struct device_info
| ^~~~~~~~~~~
I get this when I run the example on the main page.
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string: construction from null is not valid
The debugger referenced the code here as the issue:
result.emplace_back(
iterator->path ,
iterator->vendor_id ,
iterator->product_id ,
iterator->serial_number ,
iterator->release_number ,
iterator->manufacturer_string,
iterator->product_string ,
iterator->usage_page ,
iterator->usage ,
iterator->interface_number ,
static_cast<bus_type>(iterator->bus_type));
Ubuntu 23.10
hidapi: 0.14.0
hid.hpp: 0.14.0
Thanks
Edit: Never mind, it happens when default value 0 is in:
enumerate (const std::uint16_t vendor_id = 0, const std::uint16_t product_id = 0)
Run log: I want to build the tests so I changed CMakeLists.txt a little bit.
PS C:\work\hid\hid.hpp> git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fcd6c9d..0f5f6b4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,7 @@ else ()
endif()
################################################## Options ##################################################
-option(BUILD_TESTS "Build tests." OFF)
+option(BUILD_TESTS "Build tests." ON)
################################################## Sources ##################################################
file(GLOB_RECURSE PROJECT_HEADERS include/*.h include/*.hpp include/*.ipp)
PS C:\work\hid\hid.hpp> .\bootstrap.bat
C:\work\hid\hid.hpp>if not exist "build" mkdir build
C:\work\hid\hid.hpp>cd build
C:\work\hid\hid.hpp\build>if not exist "vcpkg" git clone https://github.com/Microsoft/vcpkg.git
C:\work\hid\hid.hpp\build>cd vcpkg
C:\work\hid\hid.hpp\build\vcpkg>if not exist "vcpkg.exe" call bootstrap-vcpkg.bat
C:\work\hid\hid.hpp\build\vcpkg>set VCPKG_DEFAULT_TRIPLET=x64-windows
C:\work\hid\hid.hpp\build\vcpkg>vcpkg install --recurse doctest hidapi
Computing installation plan...
The following packages are already installed:
doctest:x64-windows -> 2.4.11
hidapi:x64-windows -> 0.14.0
doctest:x64-windows is already installed
hidapi:x64-windows is already installed
Total install time: 1.1 ms
doctest provides CMake targets:
# this is heuristically generated, and may not be correct
find_package(doctest CONFIG REQUIRED)
target_link_libraries(main PRIVATE doctest::doctest)
hidapi provides CMake targets:
# this is heuristically generated, and may not be correct
find_package(hidapi CONFIG REQUIRED)
target_link_libraries(main PRIVATE hidapi::hidapi hidapi::winapi hidapi::include)
C:\work\hid\hid.hpp\build\vcpkg>cd ..
C:\work\hid\hid.hpp\build>cmake -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake ..
CMake Error at CMakeLists.txt:3 (project):
Generator
Ninja
does not support platform specification, but platform
x64
was specified.
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
C:\work\hid\hid.hpp\build>cmake --build . --clean-first --target ALL_BUILD --config Release --parallel 8
CMake Error:
Generator
Ninja
does not support platform specification, but platform
x64
was specified.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.