Skip to content

Commit be30072

Browse files
committed
解决编译重定义问题,修改为头文件和内联函数
1 parent 909bfb6 commit be30072

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

native/cpp/quickjs_extend_libraries.cpp renamed to native/cpp/quickjs_extend_libraries.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ const char *CONSOLE = R"lit(// Init format at first.
338338
})lit";
339339

340340

341-
void loadExtendLibraries(JSContext *ctx) {
341+
static inline void loadExtendLibraries(JSContext *ctx) {
342342
JS_Eval(ctx, DATE_POLYFILL, strlen(DATE_POLYFILL), "date-polyfill.js", JS_EVAL_TYPE_GLOBAL);
343343
JS_FreeValue(ctx, JS_Eval(ctx, CONSOLE, strlen(CONSOLE), "console.js", JS_EVAL_TYPE_GLOBAL));
344344
}

native/cpp/quickjs_wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44
#include "quickjs_wrapper.h"
55
#include "../quickjs/cutils.h"
6-
#include "quickjs_extend_libraries.cpp"
6+
#include "quickjs_extend_libraries.h"
77
#include <cstring>
88
#include <cmath>
99

wrapper-js/src/index.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const TAB = " "
55

66
const DIR_EXTEND_LIBRARIES = "./wrapper-js/extend/libraries/"
77
const DIR_CPP = "./native/cpp/"
8-
const FILE_CPP = DIR_CPP + "quickjs_extend_libraries.cpp"
8+
const FILE_CPP = DIR_CPP + "quickjs_extend_libraries.h"
99

1010
if (existDir(FILE_CPP)) {
1111
removeFile(FILE_CPP)
@@ -46,7 +46,7 @@ if (existDir(FILE_CPP)) {
4646
code += LINE.repeat(2)
4747

4848
// 定义入口方法
49-
code += "void loadExtendLibraries(JSContext *ctx) {"
49+
code += "static inline void loadExtendLibraries(JSContext *ctx) {"
5050
code += LINE
5151

5252
code += TAB

0 commit comments

Comments
 (0)