Skip to content

Commit 59a1fd7

Browse files
committed
Fix linker problems when compiling as C++.
When compiling compat-5.3.c as C++, the Lua symbols may still have C-linkage. Reference those symbols as `extern "C"` by default and add an option for normal (C++) linkage.
1 parent e7b17a6 commit 59a1fd7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

c-api/compat-5.3.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#include <string.h>
44
#include <ctype.h>
55
#include <errno.h>
6-
#include <lua.h>
7-
#include <lauxlib.h>
86
#include "compat-5.3.h"
97

108
/* don't compile it again if it already is included via compat53.h */

c-api/compat-5.3.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44
#include <stddef.h>
55
#include <limits.h>
66
#include <string.h>
7+
#if defined( __cplusplus ) && !defined( COMPAT53_LUA_CPP )
8+
extern "C" {
9+
#endif
710
#include <lua.h>
811
#include <lauxlib.h>
12+
#if defined( __cplusplus ) && !defined( COMPAT53_LUA_CPP )
13+
}
14+
#endif
915

1016

1117
#if defined(COMPAT53_PREFIX)

0 commit comments

Comments
 (0)