Making third-party plugins for Dovecot is really hard and frustrating. Using dovecot 2.2.33.2 and the following sources, the compile errors keep coming. The use of g++ is mandated as the underlying backend this plugin will access only has a C++ interface.
== Source 1 /* g++-7 -c a.cpp */ #include <byteswap.h> #include <dovecot/lib.h> #include <dovecot/auth-request.h> #include <dovecot/passdb.h> static enum passdb_result authdb_mapi_logon(struct auth_request *rq, const char *password) { int x = dev_null_fd + bswap_16(1); }
== Problems 1 /usr/include/dovecot/compat.h:45:4: error: #error uoff_t size not set # error uoff_t size not set
== Source 2 /* g++-7 -DHAVE_CONFIG_H -c a.cpp */ #include "config.h" /* generated by my configure */ #include <byteswap.h> #include <dovecot/lib.h> #include <dovecot/auth-request.h> #include <dovecot/passdb.h> static enum passdb_result authdb_mapi_logon(struct auth_request *rq, const char *password) { int x = dev_null_fd + bswap_16(1); }
== Problems 2 In file included from /usr/include/bits/byteswap.h:35:0, from /usr/include/byteswap.h:24, from a.cpp:2: /usr/include/dovecot/byteorder.h:32:24: error: expected unqualified-id before ‘__extension__’ static inline uint16_t bswap_16(uint16_t in);
== Other problems dovecot headers files are missing 'extern "C"' lines. This means the linkage of symbols like dev_null_fd is not what it should be. I can't use extern "C" { #include <dovecot/...> } either because then the standardy library headers that are included by dovecot headers can easily start acting up too.