Skip to content

Commit 2c30898

Browse files
authored
Update buildcpp.py
1 parent 321ecd2 commit 2c30898

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

buildcpp.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,41 @@
44
cpps = glob.glob("cpp/**/*.cpp")
55
for cpp in cpps:
66
print(cpp)
7-
code = ["#include <bits/stdc++.h>\nusing namespace std;\n"]
7+
code = '''
8+
#include <bits/stdc++.h>
9+
using namespace std;
10+
struct TreeNode {
11+
int val;
12+
TreeNode *left;
13+
TreeNode *right;
14+
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
15+
};
16+
struct ListNode {
17+
int val;
18+
ListNode *next;
19+
ListNode(int x) : val(x), next(NULL) {}
20+
};
21+
struct RandomListNode {
22+
int label;
23+
RandomListNode *next, *random;
24+
RandomListNode(int x) : label(x), next(NULL), random(NULL) {}
25+
};
26+
struct Interval {
27+
int start;
28+
int end;
29+
Interval() : start(0), end(0) {}
30+
Interval(int s, int e) : start(s), end(e) {}
31+
};
32+
struct TreeLinkNode {
33+
int val;
34+
TreeLinkNode *left, *right, *next;
35+
TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {}
36+
};
37+
'''
838
with open(cpp) as f:
9-
code += f.readlines()
39+
code += f.read()
1040
with open("a.cpp", "w") as f:
1141
f.writelines(code)
12-
cmd = "g++ a.cpp -o a.so -shared -std=c++17"
42+
cmd = "g++ a.cpp -o a.so -shared -fpic -std=c++17"
1343
if 0 != os.system(cmd):
1444
exit(-1)

0 commit comments

Comments
 (0)