I’ve got a valid swig .i file, and I’ve got as far as:
go mod init skirmish-dev.net/sgd
swig -go -I../include sgd.i
go build
…at which point I get an error:
sgd_wrap.c:211:10: fatal error: sgd/sgd.h: No such file or directory
211 | #include <sgd/sgd.h>
The problem appears to be that I haven’t passed the include directory for sgd/sgd.h to ‘go build’ the way I have to ‘swig’. I have tried -Iblah with go build but it gives an error.
I have tried to compile the sgd_wrap.c file generated by swig with gcc but it doesn’t build, it actually doesn’t look like valid ‘C’.
I there some way to pass include directories to go build, or some other way to build the sgd_wrap.c file?
Okay, just tried copying the headers files into the same directory as the module and I get a bit further, but ‘go build’ now fails with the same errors I get when trying to build with plain gcc. Here are a few of those errors, but there are hundreds…
In file included from sgd_wrap.c:179:
c:\users\marks\dev\mingw\x86_64-w64-mingw32\include\string.h:50:45: note: expected 'void * restrict' but argument is of type 'SGD_String' {aka 'const char *'}
50 | void * __cdecl memcpy(void * __restrict__ _Dst,const void * __restrict__ _Src,size_t _Size) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
| ~~~~~~~~~~~~~~~~~~~~^~~~
sgd_wrap.c:1895:22: error: assignment of read-only location '*(arg1 + (sizetype)_swig_go_0.n)'
1895 | arg1[_swig_go_0.n] = '\0';
| ^
sgd_wrap.c:1901:8: warning: passing argument 1 of 'free' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1901 | free(arg1);
| ^~~~
In file included from sgd_wrap.c:178:
c:\users\marks\dev\mingw\x86_64-w64-mingw32\include\stdlib.h:536:27: note: expected 'void *' but argument is of type 'SGD_String' {aka 'const char *'}
536 | void __cdecl free(void *_Memory);
| ~~~~~~^~~~~~~
sgd_wrap.c: In function '_wrap_LoadSkybox_sgd_f7b3eb29aefada5b':
sgd_wrap.c:1984:10: warning: passing argument 1 of 'memcpy' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1984 | memcpy(arg1, _swig_go_0.p, _swig_go_0.n);
| ^~~~