Skip to content

Commit 3e01997

Browse files
authored
Merge pull request swig#1398 from swig-fortran/missing-includes
Add missing includes to library and test cases
2 parents b66926b + c041ac6 commit 3e01997

25 files changed

+106
-50
lines changed

Examples/test-suite/char_strings.i

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ below.
1111

1212
%{
1313
#include <stdio.h>
14+
#include <string.h>
1415

1516
#define OTHERLAND_MSG "Little message from the safe world."
1617
#define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible."
@@ -150,11 +151,11 @@ const char global_const_char_array2[sizeof(CPLUSPLUS_MSG)+1] = CPLUSPLUS_MSG;
150151
%inline {
151152
struct Formatpos;
152153
struct OBFormat;
153-
154+
154155
static int GetNextFormat(Formatpos& itr, const char*& str,OBFormat*& pFormat) {
155156
return 0;
156157
}
157-
158+
158159

159160

160161
}

Examples/test-suite/default_args.i

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
%{
1919
#define TESTCASE_THROW1(T1)
2020
#define TESTCASE_THROW2(T1, T2)
21+
#include <string.h>
2122
%}
2223

2324
%include <std_string.i>
@@ -71,7 +72,7 @@
7172
class EnumClass {
7273
public:
7374
enum speed { FAST, SLOW };
74-
// Note: default values should be EnumClass::FAST and SWEET
75+
// Note: default values should be EnumClass::FAST and SWEET
7576
bool blah(speed s = FAST, flavor f = SWEET) { return (s == FAST && f == SWEET); };
7677
};
7778

@@ -83,16 +84,16 @@
8384

8485
// casts
8586
const char * casts1(const char *m = (const char *) NULL) {
86-
char *ret = NULL;
87-
if (m) {
87+
char *ret = NULL;
88+
if (m) {
8889
ret = new char[strlen(m)+1];
8990
strcpy(ret, m);
9091
}
9192
return ret;
9293
}
9394
const char * casts2(const char *m = (const char *) "Hello") {
94-
char *ret = NULL;
95-
if (m) {
95+
char *ret = NULL;
96+
if (m) {
9697
ret = new char[strlen(m)+1];
9798
strcpy(ret, m);
9899
}
@@ -108,16 +109,16 @@
108109
char chartest6(char c = '\x43') { return c; } // 'C'
109110

110111
// namespaces
111-
namespace AType {
112-
enum AType { NoType };
113-
}
112+
namespace AType {
113+
enum AType { NoType };
114+
}
114115
void dummy(AType::AType aType = AType::NoType) {}
115-
namespace A {
116-
namespace B {
117-
int CONST_NUM = 10;
118-
}
116+
namespace A {
117+
namespace B {
118+
int CONST_NUM = 10;
119+
}
119120
int afunction(int i = B::CONST_NUM) { return i; }
120-
}
121+
}
121122

122123
// references
123124
int reftest1(const int &x = 42) { return x; }
@@ -131,7 +132,7 @@
131132
void test(int x = Oak + Fir + Cedar) {}
132133
};
133134
enum Tree::types chops(enum Tree::types type) { return type; }
134-
135+
135136
%}
136137

137138
// Rename a class member
@@ -155,11 +156,11 @@
155156
static int spam;
156157

157158
Foo(){}
158-
159+
159160
Foo(int x, int y = 0, int z = 0){}
160161

161162
void meth(int x, int y = 0, int z = 0){}
162-
163+
163164
// Use a renamed member as a default argument. SWIG has to resolve
164165
// bar to Foo::bar and not Foo::spam. SWIG-1.3.11 got this wrong.
165166
// (Different default parameter wrapping in SWIG-1.3.23 ensures SWIG doesn't have to resolve these symbols).
@@ -189,20 +190,20 @@
189190
// tests valuewrapper
190191
%feature("compactdefaultargs") MyClass2::set;
191192
%inline %{
192-
enum MyType { Val1, Val2 };
193+
enum MyType { Val1, Val2 };
193194

194-
class MyClass1
195-
{
196-
public:
195+
class MyClass1
196+
{
197+
public:
197198
MyClass1(MyType myType) {}
198-
};
199+
};
199200

200-
class MyClass2
201-
{
202-
public :
201+
class MyClass2
202+
{
203+
public :
203204
void set(MyClass1 cl1 = Val1) {}
204-
// This could have been written : set(MyClass1 cl1 = MyClass1(Val1))
205-
// But it works in C++ since there is a "conversion" constructor in MyClass1.
205+
// This could have been written : set(MyClass1 cl1 = MyClass1(Val1))
206+
// But it works in C++ since there is a "conversion" constructor in MyClass1.
206207
void set2(MyClass1 cl1 = Val1) {}
207208
};
208209
%}
@@ -281,7 +282,7 @@ struct ConstMethods {
281282
};
282283
%}
283284

284-
// const methods
285+
// const methods
285286
// runtime test needed to check that the const method is called
286287
struct ConstMethods {
287288
int coo(double d = 0.0) const;
@@ -305,8 +306,8 @@ struct ConstMethods {
305306
return(x+p);
306307
}
307308

308-
typedef struct Pointf {
309-
double x,y;
309+
typedef struct Pointf {
310+
double x,y;
310311
} Pointf;
311312
}
312313
%}

Examples/test-suite/director_thread.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#ifdef _WIN32
2121
#include <windows.h>
2222
#include <process.h>
23-
#include <stdio.h>
2423
#else
2524
#include <pthread.h>
2625
#include <errno.h>
@@ -30,6 +29,7 @@
3029
#endif
3130

3231
#include <assert.h>
32+
#include <stdio.h>
3333
#include "swig_examples_lock.h"
3434

3535
class Foo;

Examples/test-suite/li_cdata.i

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55
%cdata(int);
66
%cdata(double);
77

8+
%{
9+
#include <stdlib.h>
10+
%}
11+
812
void *malloc(size_t size);

Examples/test-suite/li_cdata_cpp.i

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55
%cdata(int);
66
%cdata(double);
77

8+
%{
9+
#include <stdlib.h>
10+
%}
11+
812
void *malloc(size_t size);

Examples/test-suite/li_std_except.i

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
%}
1010

1111
%inline %{
12+
#include <stdexcept>
13+
#include <typeinfo>
1214
struct E1 : public std::exception
1315
{
1416
};

Examples/test-suite/memberin_extend.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct ExtendMe {
1111

1212
%{
1313
#include <map>
14+
#include <string.h>
1415
std::map<ExtendMe*, char *> ExtendMeStringMap;
1516
void ExtendMe_thing_set(ExtendMe *self, const char *val) {
1617
char *old_val = ExtendMeStringMap[self];

Examples/test-suite/mod.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
#include <cstddef>
22

33
class C;
44

Examples/test-suite/namespace_typemap.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
%module namespace_typemap
33

44
%{
5+
#include <string.h>
56
namespace test {
67
/* A minimalistic string class */
78
class string_class {

Examples/test-suite/nested_extend_c.i

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
#endif
1414

15+
%{
16+
#include "stdlib.h"
17+
%}
18+
1519
#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8)
1620
%extend hiA {
1721
hiA() {

0 commit comments

Comments
 (0)