Skip to content

Commit e65cb95

Browse files
committed
Fix. Do not use redefine typedefs as forward declaration.
1 parent 00c1bc4 commit e65cb95

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

.travis.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,22 @@ matrix:
66
include:
77
- compiler: ": Lua51"
88
env: LUA="lua 5.1"
9+
os: osx
10+
- compiler: ": Lua51"
11+
env: LUA="lua 5.1"
12+
os: linux
913
- compiler: ": Lua52"
1014
env: LUA="lua 5.2"
15+
os: linux
1116
- compiler: ": Lua53"
1217
env: LUA="lua 5.3"
18+
os: linux
1319
- compiler: ": LuaJIT20"
1420
env: LUA="luajit 2.0"
21+
os: linux
1522
- compiler: ": LuaJIT21"
1623
env: LUA="luajit 2.1"
24+
os: linux
1725

1826
cache:
1927
directories:
@@ -26,10 +34,11 @@ branches:
2634

2735
before_install:
2836
- export CC=gcc
37+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=$PATH:~/Library/Python/2.7/bin/; fi
2938
- pip install --user cpp-coveralls
3039
- pip install --user hererocks
3140
- hererocks here -r^ --$LUA
32-
- export PATH=$PATH:$PWD/here/bin
41+
- source here/bin/activate
3342

3443
install:
3544
- luarocks make rockspecs/lua-curl-scm-0.rockspec CFLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="-shared --coverage"

src/lceasy.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ enum {
3535

3636
#define LCURL_EASY_MAGIC 0xEA
3737

38+
#if LCURL_CC_SUPPORT_FORWARD_TYPEDEF
3839
typedef struct lcurl_multi_tag lcurl_multi_t;
40+
#else
41+
struct lcurl_multi_tag;
42+
#define lcurl_multi_t struct lcurl_multi_tag
43+
#endif
3944

4045
typedef struct lcurl_easy_tag{
4146
unsigned char magic;
@@ -67,4 +72,8 @@ void lcurl_easy_initlib(lua_State *L, int nup);
6772

6873
void lcurl__easy_assign_lua(lua_State *L, lcurl_easy_t *p, lua_State *value, int assign_multi);
6974

75+
#if !LCURL_CC_SUPPORT_FORWARD_TYPEDEF
76+
#undef lcurl_multi_t
77+
#endif
78+
7079
#endif

src/lcmulti.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ typedef struct lcurl_multi_tag{
2323
lcurl_callback_t sc;
2424
}lcurl_multi_t;
2525

26+
27+
#if LCURL_CC_SUPPORT_FORWARD_TYPEDEF
28+
typedef struct lcurl_multi_tag lcurl_multi_t;
29+
#else
30+
struct lcurl_easy_tag;
31+
#define lcurl_easy_t struct lcurl_easy_tag
32+
#endif
33+
2634
int lcurl_multi_create(lua_State *L, int error_mode);
2735

2836
lcurl_multi_t *lcurl_getmulti_at(lua_State *L, int i);
@@ -35,4 +43,8 @@ void lcurl__multi_assign_lua(lua_State *L, lcurl_multi_t *p, lua_State *value, i
3543

3644
CURLMcode lcurl__multi_remove_handle(lua_State *L, lcurl_multi_t *p, lcurl_easy_t *e);
3745

46+
#if !LCURL_CC_SUPPORT_FORWARD_TYPEDEF
47+
#undef lcurl_easy_t
48+
#endif
49+
3850
#endif

src/lcutils.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313

1414
#include "lcurl.h"
1515

16+
#ifdef _MSC_VER
17+
# define LCURL_CC_SUPPORT_FORWARD_TYPEDEF 1
18+
#elif defined(__STDC_VERSION__)
19+
# if __STDC_VERSION__ >= 201112
20+
# define LCURL_CC_SUPPORT_FORWARD_TYPEDEF 1
21+
# endif
22+
#endif
23+
24+
#ifndef LCURL_CC_SUPPORT_FORWARD_TYPEDEF
25+
# define LCURL_CC_SUPPORT_FORWARD_TYPEDEF 0
26+
#endif
27+
1628
#define LCURL_MAKE_VERSION(MIN, MAJ, PAT) ((MIN<<16) + (MAJ<<8) + PAT)
1729
#define LCURL_CURL_VER_GE(MIN, MAJ, PAT) (LIBCURL_VERSION_NUM >= LCURL_MAKE_VERSION(MIN, MAJ, PAT))
1830

0 commit comments

Comments
 (0)