Skip to content

IAUSB

IAUSB is a USB library for C++. It is built on top of libusb and provides a modern, memory-safe C++23 module API. It uses the Auxid platform for memory management and error handling.

Requirements

  • CMake 3.28+
  • C++23 with module support (Clang, MSVC, or GCC 15.2+)
  • libusb (linked dynamically by default)

The public API is modules-only — use import iausb; (no headers).

Core features

  • Clean, memory-safe abstraction over libusb
  • Automatic resource cleanup via Auxid Box and custom deleters
  • Error handling with au::Result instead of exceptions
  • Device discovery with std::regex matching on manufacturer and product strings
  • Cross-platform support on Windows and Linux

Quick start (CMake)

Integrate IAUSB into your project using CMake's FetchContent:

include(FetchContent)

FetchContent_Declare(
    iausb
    GIT_REPOSITORY https://github.com/I-A-S/iausb.git
    GIT_TAG        main
)
FetchContent_MakeAvailable(iausb)

target_link_libraries(your_target PRIVATE iausb)

Example

#include <utility>

#include <auxid/macros.hpp>

import iausb;

using namespace au;

auto app_main() -> Result<void>
{
  AU_TRY_VAR(context, iausb::create_context());
  AU_TRY_VAR(device, iausb::find_device(context, "Altera", "USB-Blaster"));
  AU_TRY_VAR(connection, iausb::open_device(device, 0));

  static const u8 write_data[] = {static_cast<u8>(1 << 5)};
  AU_TRY_DISCARD(iausb::write(connection, 0x02, Span<const u8>(write_data)));

  return {};
}

API Reference

Browse the full API documentation generated from source comments:

Note: mkdoxy's generic Modules and File Functions index pages are empty for this project because IAUSB uses C++23 modules and namespace-scoped APIs rather than Doxygen @defgroup groups or file-global functions.

Building this site locally

Install Doxygen 1.9.8+, Python 3, and MkDocs dependencies (including mkdoxy):

pip install -r docs/requirements.txt
cd docs && mkdocs serve

Doxygen runs automatically via the mkdoxy plugin during mkdocs build or mkdocs serve.

Or build via CMake from the project root:

cmake --preset iausb-x64-linux
cmake --build --preset iausb-x64-linux --target docs

Open docs/site/index.html in a browser.