#define MY_LIBRARY_EXPORTS #ifdef _WIN32 // Windows 平台 #ifdef MY_LIBRARY_EXPORTS // 如果正在构建库 #define MY_LIBRARY_API __declspec(dllexport) // 导出符号 #else #define MY_LIBRARY_API __declspec(dllimport) // 导入符号 #endif #else // 对于 Linux 和其他 Unix-like 系统 #define MY_LIBRARY_API __attribute__((visibility("default"))) // 导出符号 #endif #include #include extern "C" { #pragma pack(push, 8) struct MLAT_Data { char icao[6]; double lon; double lat; }; #pragma pack(pop) MY_LIBRARY_API void read(MLAT_Data* buf, std::uint16_t* len); }