Discussion:
[Swig-devel] SWIG_strnlen() not static
b***@yahoo.com
2017-01-17 15:27:59 UTC
Permalink
Hi,
If I've a character array in my '.i' file, SWIG generates SWIG_strnlen() function in the wrapper file. However, this function is not qualified with 'SWIGINTERN'. Since this function is not marked static, when linking multiple modules together, this results in linker errors. Wouldn't it be better to mark SWIG_strnlen() static? I can see this issue in SWIG version 3.0.11.
Example:

$ cat test.i
%module test
char test_str[100];
$ swig -python test.i

$ egrep --before-context 2 SWIG_strnlen test_wrap.c
size_tSWIG_strnlen(const char* s, size_t maxlen)--    {    size_t size = SWIG_strnlen(test_str, 100);
We can see that other functions are marked as static inline:
$ egrep --before-context 2 SWIG_FromChar test_wrap.c
SWIGINTERNINLINE PyObject *SWIG_FromCharPtrAndSize(const char* carray, size_t size)--
Thanks,Balaji
William S Fulton
2017-01-17 20:11:29 UTC
Permalink
Post by b***@yahoo.com
Hi,
If I've a character array in my '.i' file, SWIG generates SWIG_strnlen()
function in the wrapper file. However, this function is not qualified with
'SWIGINTERN'. Since this function is not marked static, when linking
multiple modules together, this results in linker errors. Wouldn't it be
better to mark SWIG_strnlen() static? I can see this issue in SWIG version
3.0.11.
$ cat test.i
%module test
char test_str[100];
$ swig -python test.i
$ egrep --before-context 2 SWIG_strnlen test_wrap.c
size_t
SWIG_strnlen(const char* s, size_t maxlen)
--
{
size_t size = SWIG_strnlen(test_str, 100);
$ egrep --before-context 2 SWIG_FromChar test_wrap.c
SWIGINTERNINLINE PyObject *
SWIG_FromCharPtrAndSize(const char* carray, size_t size)
--
I've committed a fix on master.

William
b***@yahoo.com
2017-01-18 02:52:35 UTC
Permalink
Thanks, William.


On Wednesday, January 18, 2017 1:42 AM, William S Fulton <***@fultondesigns.co.uk> wrote:




On 17 January 2017 at 15:27, <***@yahoo.com> wrote:

Hi,
If I've a character array in my '.i' file, SWIG generates SWIG_strnlen() function in the wrapper file. However, this function is not qualified with 'SWIGINTERN'. Since this function is not marked static, when linking multiple modules together, this results in linker errors. Wouldn't it be better to mark SWIG_strnlen() static? I can see this issue in SWIG version 3.0.11.
Example:

$ cat test.i
%module test
char test_str[100];
$ swig -python test.i

$ egrep --before-context 2 SWIG_strnlen test_wrap.c
size_tSWIG_strnlen(const char* s, size_t maxlen)--    {    size_t size = SWIG_strnlen(test_str, 100);
We can see that other functions are marked as static inline:
$ egrep --before-context 2 SWIG_FromChar test_wrap.c
SWIGINTERNINLINE PyObject *SWIG_FromCharPtrAndSize(const char* carray, size_t size)--


I've committed a fix on master.

William

Loading...