Skip to content

Commit fb2c141

Browse files
committed
Clean up lua includes
There was a bit of a mess of different (types of) includes. We now only use '#include <lua.hpp>' which includes all Lua C headers correctly and also works for LuaJIT. Technically it might include more than we need in some cases, because lua.hpp includes several C headers some of which are only needed sometimes, but the largest one (lua.h) is the one we always need, the others are tiny.
1 parent 52272ca commit fb2c141

11 files changed

+13
-57
lines changed

src/command-line-parser.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,16 @@
2121

2222
#include <getopt.h>
2323

24+
#ifdef HAVE_LUA
25+
#include <lua.hpp>
26+
#endif
27+
2428
#include <algorithm>
2529
#include <cstdio>
2630
#include <cstring>
2731
#include <stdexcept>
2832
#include <thread> // for number of threads
2933

30-
#ifdef HAVE_LUA
31-
extern "C"
32-
{
33-
#include <lua.h>
34-
}
35-
#endif
36-
37-
#ifdef HAVE_LUAJIT
38-
extern "C"
39-
{
40-
#include <luajit.h>
41-
}
42-
#endif
43-
4434
static char const *program_name(char const *name)
4535
{
4636
char const *const slash = std::strrchr(name, '/');

src/flex-lua-geom.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212
#include "geom-pole-of-inaccessibility.hpp"
1313
#include "lua-utils.hpp"
1414

15-
extern "C"
16-
{
17-
#include <lauxlib.h>
18-
#include <lua.h>
19-
}
15+
#include <lua.hpp>
2016

2117
static char const *const osm2pgsql_geometry_class = "osm2pgsql.Geometry";
2218

src/geom-transform.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
#include <osmium/fwd.hpp>
1818
#include <osmium/memory/buffer.hpp>
1919

20-
extern "C"
21-
{
22-
#include <lua.h>
23-
}
20+
#include <lua.hpp>
2421

2522
#include <memory>
2623

src/lua-utils.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@
88
*/
99

1010
#include "lua-utils.hpp"
11-
#include "format.hpp"
1211

13-
extern "C"
14-
{
15-
#include <lauxlib.h>
16-
}
12+
#include "format.hpp"
1713

1814
#include <cassert>
1915
#include <stdexcept>

src/lua-utils.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313
// This file contains helper functions for talking to Lua. It is used from
1414
// the flex output backend. All functions start with "luaX_".
1515

16-
extern "C"
17-
{
18-
#include <lua.h>
19-
}
16+
#include <lua.hpp>
2017

2118
#include <cassert>
2219
#include <cstdint>

src/output-flex.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@
3939

4040
#include <osmium/osm/types_from_string.hpp>
4141

42-
extern "C"
43-
{
44-
#include <lauxlib.h>
45-
#include <lualib.h>
46-
}
47-
4842
#include <cassert>
4943
#include <cstdlib>
5044
#include <cstring>

src/output-flex.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
#include <osmium/index/id_set.hpp>
2222
#include <osmium/osm/item_type.hpp>
2323

24-
extern "C"
25-
{
26-
#include <lua.h>
27-
}
24+
#include <lua.hpp>
2825

2926
#include <cstdint>
3027
#include <memory>

src/tagtransform-lua.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
* For a full list of authors see the git log.
88
*/
99

10-
extern "C"
11-
{
12-
#include <lauxlib.h>
13-
#include <lualib.h>
14-
}
15-
1610
#include "format.hpp"
1711
#include "lua-utils.hpp"
1812
#include "tagtransform-lua.hpp"

src/tagtransform-lua.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414

1515
#include "tagtransform.hpp"
1616

17-
extern "C"
18-
{
19-
#include <lua.h>
20-
}
17+
#include <lua.hpp>
2118

2219
class lua_tagtransform_t : public tagtransform_t
2320
{

tests/test-flex-indexes.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
#include "flex-lua-index.hpp"
1313
#include "flex-table.hpp"
14-
#include "lua.hpp"
1514
#include "pgsql-capabilities-int.hpp"
1615

16+
#include <lua.hpp>
17+
1718
class test_framework
1819
{
1920
public:

0 commit comments

Comments
 (0)