Mark 'externc' storage for variables

This commit is contained in:
Seth R Johnson 2019-04-23 19:26:53 -04:00
parent d47970e2fd
commit befc9bc1f0
3 changed files with 14 additions and 2 deletions

View File

@ -5,6 +5,7 @@ extern "C" {
void RealFunction(int value);
typedef void Function1(int value); // Fails
typedef int Integer1;
int Integer3;
}
typedef void Function2(int value); // Works
typedef int Integer2;
@ -27,5 +28,14 @@ Hook2_t hook2;
extern "C" typedef int Integer;
Integer int1;
extern "C" int int2;
extern "C" { extern int int3; }
extern "C" { int int4 = 789; }
%}
%{
extern "C" {
int int2 = 123;
int int3 = 456;
}
%}

View File

@ -1,3 +1,6 @@
import extern_c
extern_c.RealFunction(2)
assert extern_c.cvar.int2 == 123
assert extern_c.cvar.int3 == 456
assert extern_c.cvar.int4 == 789

View File

@ -3133,8 +3133,7 @@ c_declaration : c_decl {
Setattr($$,"name",$2);
appendChild($$,n);
while (n) {
SwigType *decl = Getattr(n,"decl");
if (SwigType_isfunction(decl) && !Equal(Getattr(n, "storage"), "typedef")) {
if (!Equal(Getattr(n, "storage"), "typedef")) {
Setattr(n,"storage","externc");
}
n = nextSibling(n);