when use libxdo, it raise "error: unknown type name ‘useconds_t’"

when use libxdo, it raise "error: unknown type name ‘useconds_t’"

这是我的 CMakeLists.txt:

cmake_minimum_required(VERSION 3.3)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_executable(ex ex.c)
target_link_libraries(ex xdo)

完整代码是here

当然,libxdo.so和xdo.h是存在的

找到原因了,useconds_t在"unistd.h",但是需要先用#define __USE_XOPEN,正确的代码是

#include "unistd.h"
#define __USE_XOPEN
#include <xdo.h>

检查的答案是错误的,正确的解决方案是:

#define __USE_XOPEN
#include "unistd.h"
#include <xdo.h>