Some fixes to linking problems.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10642 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Maciej Drwal 2008-07-03 14:55:03 +00:00
commit b2d56dee8e
3 changed files with 43 additions and 17 deletions

View file

@ -5,6 +5,8 @@
* c.swg
* ----------------------------------------------------------------------------- */
%insert("runtime") "clabels.swg"
%typemap(ctype) void, short, int, long, char, float, double "$1_type"
%typemap(ctype) void*, short*, int*, long*, char*, float*, double* "$1_type"
%typemap(ctype) bool "_Bool"

38
Lib/c/clabels.swg Normal file
View file

@ -0,0 +1,38 @@
/* -----------------------------------------------------------------------------
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
*
* clabels.swg
*
* Definitions of some C specific preprocessor symbols.
* ----------------------------------------------------------------------------- */
// this is used instead of default SWIGEXPORT symbol
#ifndef SWIGEXPORTC
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# if defined(STATIC_LINKED)
# define SWIGEXPORTC
# else
# define SWIGEXPORTC
# endif
# else
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
# define SWIGEXPORTC __attribute__ ((visibility("default")))
# else
# define SWIGEXPORTC
# endif
# endif
#endif
#ifndef SWIGPROTECT
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# define SWIGPROTECT(x)
# else
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
# define SWIGPROTECT(x) __attribute__ ((visibility("protected"))) x
# else
# define SWIGPROTECT(x)
# endif
# endif
#endif

View file

@ -73,20 +73,6 @@ public:
}
}
void emitSwigProtectSymbols(File *f) {
Printf(f, "#ifndef SWIGPROTECT\n");
Printf(f, "# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\n");
Printf(f, "# define SWIGPROTECT(x)\n");
Printf(f, "# else\n");
Printf(f, "# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)\n");
Printf(f, "# define SWIGPROTECT(x) __attribute__ ((visibility(\"protected\"))) x\n");
Printf(f, "# else\n");
Printf(f, "# define SWIGPROTECT(x)\n");
Printf(f, "# endif\n");
Printf(f, "# endif\n");
Printf(f, "#endif\n\n");
}
void emitSwigImport(File *f) {
Printf(f, "#ifndef SWIGIMPORT\n");
Printf(f, "# ifndef __GNUC__\n");
@ -121,11 +107,11 @@ public:
f_wrappers = NewString("");
Swig_banner(f_runtime);
emitSwigProtectSymbols(f_header);
Printf(f_header, "#include <malloc.h>\n");
if (runtime_flag) {
Printf(f_header, "#include <stdio.h>\n");
Printf(f_header, "#include <stdlib.h>\n");
Printf(f_header, "#include <string.h>\n");
Printf(f_header, "#include <setjmp.h>\n\n");
Printf(f_header, "static jmp_buf __rt_env;\n");
@ -220,7 +206,7 @@ public:
virtual int globalvariableHandler(Node *n) {
SwigType *type = Getattr(n, "type");
String *type_str = SwigType_str(type, 0);
Printv(f_wrappers, "SWIGEXPORT ", type_str, " ", Getattr(n, "name"), ";\n", NIL);
//Printv(f_wrappers, "SWIGEXPORTC ", type_str, " ", Getattr(n, "name"), ";\n", NIL);
if (shadow_flag) {
Printv(f_shadow_header, "SWIGIMPORT ", type_str, " ", Getattr(n, "name"), ";\n", NIL);
}
@ -312,7 +298,7 @@ public:
}
// create wrapper function prototype
Printv(wrapper->def, "SWIGEXPORT ", return_type, " ", wname, "(", NIL);
Printv(wrapper->def, "SWIGEXPORTC ", return_type, " ", wname, "(", NIL);
// prepare function definition
int gencomma = 0;