The raw lua.h include sat outside extern "C", so any C++ unit that
pulled rspamd_symcache.h before lua/lua_common.h got C++-mangled
declarations of the Lua C API and failed to link. Including
lua_common.h itself is not an option due to the include cycle via
rspamd.h -> cfg_file.h -> rspamd_symcache.h, so wrap lua.h the same
way lua_common.h does. This also lets composites sources include
lua_common.h in the natural position instead of first.
* limitations under the License.
*/
#include "config.h"
-/* Must go first to keep the C linkage of the raw lua headers */
-#include "lua/lua_common.h"
-
#include "logger.h"
#include "expression.h"
#include "task.h"
#include "composites.h"
#include "contrib/libev/ev.h"
#include "libutil/util.h"
+#include "lua/lua_common.h"
#include <cmath>
#include <vector>
* limitations under the License.
*/
-/* Must go first to keep the C linkage of the raw lua headers */
-#include "lua/lua_common.h"
-
#include <memory>
#include <vector>
#include <cmath>
#include "libserver/maps/map.h"
#include "libserver/rspamd_symcache.h"
#include "libutil/cxx/util.hxx"
+#include "lua/lua_common.h"
namespace rspamd::composites {
#include "cfg_file.h"
#include "contrib/libev/ev.h"
+/* Lua headers do not have __cplusplus guards, so keep their C linkage
+ * explicitly; including lua_common.h here is not an option as it creates
+ * an include cycle via rspamd.h -> cfg_file.h -> rspamd_symcache.h */
+#ifdef __cplusplus
+extern "C" {
+#endif
#include <lua.h>
+#ifdef __cplusplus
+}
+#endif
#ifdef __cplusplus
extern "C" {