compat.libserial
#includeLibSerial — object-oriented C++ serial-port library (SerialPort / SerialStream)
#include <libserial/SerialPortConstants.h>
mcpp add compat.libserial@1.0.0
Usage
From this repository's own test project — built and run by CI, not written for the website.
// Model a libc that provides public baud constants without glibc's private
// __MAX_BAUD helper. Include termios first so its include guard prevents the
// library header from restoring the private macro on a glibc test host.
#ifdef __linux__
#include <termios.h>
#undef __MAX_BAUD
#include <libserial/SerialPortConstants.h>
static_assert(static_cast<speed_t>(LibSerial::BaudRate::BAUD_2000000) == B2000000);
static_assert(static_cast<speed_t>(LibSerial::BaudRate::BAUD_2500000) == B2500000);
static_assert(static_cast<speed_t>(LibSerial::BaudRate::BAUD_3000000) == B3000000);
static_assert(static_cast<speed_t>(LibSerial::BaudRate::BAUD_3500000) == B3500000);
static_assert(static_cast<speed_t>(LibSerial::BaudRate::BAUD_4000000) == B4000000);
#endif
int main() { return 0; }
tests/examples/libserial/tests/baud_constants.cpp · project tests/examples/libserial
Build
- targets
serial (lib)- language
c++23- import std
- no
- include dirs
mcpp_generated, */src
Sources (3)
*/src/SerialPort.cpp*/src/SerialStream.cpp*/src/SerialStreamBuf.cpp
Generated files
mcpp_generated/libserial/SerialPortConstants.h