]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] rspamd_symcache.h: keep C linkage of lua.h for C++ includers 6126/head
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 10 Jul 2026 07:38:03 +0000 (08:38 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 10 Jul 2026 07:38:03 +0000 (08:38 +0100)
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.

src/libserver/composites/composites.cxx
src/libserver/composites/composites_manager.cxx
src/libserver/rspamd_symcache.h

index 6c69c0cc88a2bcc6aa6a943666e507b591786ff0..da0546f2bd35e2cf909ecb3336abc4aafae8d65c 100644 (file)
@@ -14,9 +14,6 @@
  * 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"
@@ -25,6 +22,7 @@
 #include "composites.h"
 #include "contrib/libev/ev.h"
 #include "libutil/util.h"
+#include "lua/lua_common.h"
 
 #include <cmath>
 #include <vector>
index 9f3628d8b407f2b0c9cd181156b14938d0da7105..a1b13754439ef76c67c17ce7a7b0634e7f916f0a 100644 (file)
@@ -14,9 +14,6 @@
  * 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>
@@ -29,6 +26,7 @@
 #include "libserver/maps/map.h"
 #include "libserver/rspamd_symcache.h"
 #include "libutil/cxx/util.hxx"
+#include "lua/lua_common.h"
 
 namespace rspamd::composites {
 
index 1ae33bd294a4789b3e39961bb46697e78f88e534..efbb327799d916712bcd8948a87039619e592462 100644 (file)
 #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" {