Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
cmake_minimum_required(VERSION 3.15)

# Set the toolchain file for vcpkg on Windows.
if(WIN32)
# Set the toolchain file for vcpkg on Windows (only if VCPKG_ROOT is set;
# on mingw we get libusb from pkg-config directly).
if(WIN32 AND NOT "$ENV{VCPKG_ROOT}" STREQUAL "")
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
endif()

Expand Down
10 changes: 9 additions & 1 deletion txdemo/stream_duplex_demo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
#include <windows.h>
typedef int pid_t;
#define sleep(seconds) Sleep((seconds)*1000)
#elif defined(__MINGW32__) || defined(__MINGW64__)
// mingw builds: POSIX libusb/unistd PLUS io.h/fcntl.h for binary stdin.
#include <io.h>
#include <fcntl.h>
#include <unistd.h>
#include <libusb-1.0/libusb.h>
#elif defined(__ANDROID__)
#include <libusb.h>
#include <unistd.h>
Expand Down Expand Up @@ -233,7 +239,9 @@ int main(int argc, char **argv) {
}
}

#if defined(_MSC_VER)
#if defined(_WIN32)
// mingw/GCC defines _WIN32 but not _MSC_VER, yet still has _setmode — make
// stdin binary so a 0x1A/CRLF doesn't corrupt the length-prefixed PSDU stream.
_setmode(_fileno(stdin), _O_BINARY);
#endif

Expand Down
9 changes: 8 additions & 1 deletion txdemo/stream_tx_demo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
#include <process.h>
typedef int pid_t;
#define sleep(seconds) Sleep((seconds)*1000)
#elif defined(__MINGW32__) || defined(__MINGW64__)
// mingw builds: POSIX libusb/unistd PLUS io.h/fcntl.h for binary stdin.
#include <io.h>
#include <fcntl.h>
#include <unistd.h>
#include <libusb-1.0/libusb.h>
#elif defined(__ANDROID__)
#include <libusb.h>
#include <unistd.h>
Expand Down Expand Up @@ -134,8 +140,9 @@ int main(int argc, char **argv) {
}
}

#if defined(_MSC_VER)
#if defined(_WIN32)
// Make stdin binary so a 0x1A or CRLF doesn't corrupt PSDU bytes.
// (mingw/GCC defines _WIN32 but not _MSC_VER, yet still has _setmode.)
_setmode(_fileno(stdin), _O_BINARY);
#endif

Expand Down
Loading