compat.libserial
#includeLibSerial — object-oriented C++ serial-port library (SerialPort / SerialStream)
#include <libserial/SerialPortConstants.h>
mcpp add compat.libserial@1.0.0
用法
來自本倉庫自己的測試專案 —— CI 真的編譯並執行過,不是為了網站寫的。
// 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 · 專案 tests/examples/libserial
建置
- targets
serial (lib)- language
c++23- import std
- no
- include dirs
mcpp_generated, */src
原始檔 (3)
*/src/SerialPort.cpp*/src/SerialStream.cpp*/src/SerialStreamBuf.cpp
產生的檔案
mcpp_generated/libserial/SerialPortConstants.h