Skip to content

Commit bde6a9d

Browse files
authored
Merge pull request #88 from moteus/master
Fix. Do not use redefine typedefs as forward declaration (Close #85)
2 parents 1cec281 + 2016233 commit bde6a9d

File tree

5 files changed

+58
-8
lines changed

5 files changed

+58
-8
lines changed

.travis.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,31 @@ language: c
22

33
sudo: false
44

5+
env:
6+
global:
7+
- LCURL_CC_FLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs"
8+
- LCURL_LD_FLAGS="-shared --coverage"
9+
510
matrix:
611
include:
12+
- compiler: ": Lua51-osx"
13+
env: LUA="lua 5.1"
14+
os: osx
715
- compiler: ": Lua51"
816
env: LUA="lua 5.1"
17+
os: linux
918
- compiler: ": Lua52"
1019
env: LUA="lua 5.2"
20+
os: linux
1121
- compiler: ": Lua53"
1222
env: LUA="lua 5.3"
23+
os: linux
1324
- compiler: ": LuaJIT20"
1425
env: LUA="luajit 2.0"
26+
os: linux
1527
- compiler: ": LuaJIT21"
1628
env: LUA="luajit 2.1"
29+
os: linux
1730

1831
cache:
1932
directories:
@@ -26,19 +39,22 @@ branches:
2639

2740
before_install:
2841
- export CC=gcc
42+
- gcc --version
43+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=$PATH:~/Library/Python/2.7/bin/; fi
44+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export LCURL_LD_FLAGS="-bundle -undefined dynamic_lookup -all_load --coverage"; fi
2945
- pip install --user cpp-coveralls
3046
- pip install --user hererocks
3147
- hererocks here -r^ --$LUA
32-
- export PATH=$PATH:$PWD/here/bin
48+
- source here/bin/activate
3349

3450
install:
35-
- luarocks make rockspecs/lua-curl-scm-0.rockspec CFLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="-shared --coverage"
51+
- luarocks make rockspecs/lua-curl-scm-0.rockspec CFLAGS="$LCURL_CC_FLAGS" LIBFLAG="$LCURL_LD_FLAGS"
3652

3753
before_script:
38-
- luarocks show luacov-coveralls || luarocks install luacov-coveralls
39-
- luarocks show lunitx || luarocks install lunitx
40-
- luarocks show luafilesystem || luarocks install luafilesystem
41-
- luarocks show dkjson || luarocks install dkjson --deps-mode=none
54+
- luarocks show luacov-coveralls > /dev/null 2>&1 || luarocks install luacov-coveralls
55+
- luarocks show lunitx > /dev/null 2>&1 || luarocks install lunitx
56+
- luarocks show luafilesystem > /dev/null 2>&1 || luarocks install luafilesystem
57+
- luarocks show dkjson > /dev/null 2>&1 || luarocks install dkjson --deps-mode=none
4258

4359
script:
4460
- cd test

appveyor.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ platform:
2121

2222
cache:
2323
- c:\hererocks -> appveyor.yml
24+
- c:\external -> appveyor.yml
2425

2526
install:
2627
- set PATH=C:\Python27\Scripts;%LR_EXTERNAL%;%PATH%
@@ -35,9 +36,9 @@ install:
3536
)
3637
- if not exist c:\hererocks (
3738
pip install hererocks &&
38-
hererocks c:\hererocks --%LUA% --target %HR_TARGET% -rlatest &&
39-
call c:\hererocks\bin\activate
39+
hererocks c:\hererocks --%LUA% --target %HR_TARGET% -rlatest
4040
)
41+
- call c:\hererocks\bin\activate
4142

4243
before_build:
4344
# external deps

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+
#if defined(_MSC_VER) || defined(__cplusplus)
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)