🐛 fix error loading bug in MSVC version

This commit is contained in:
ValKmjolnir 2023-12-02 21:48:20 +08:00
parent d42e4a5897
commit 2c03d59b6f
8 changed files with 16 additions and 7 deletions

View File

@ -593,7 +593,7 @@ module_func_info func_tbl[] = {
// the reason why using this way to get function pointer // the reason why using this way to get function pointer
// is because `var` has constructors, which is not compatiable in C // is because `var` has constructors, which is not compatiable in C
// so "extern "C" var fib" may get compilation warnings // so "extern "C" var fib" may get compilation warnings
extern "C" module_func_info* get() { NASAL_EXTERN module_func_info* get() {
return func_tbl; return func_tbl;
} }
``` ```

View File

@ -574,7 +574,7 @@ module_func_info func_tbl[] = {
// 之所以用这种方式来获取函数指针, 是因为`var`是有构造函数的 // 之所以用这种方式来获取函数指针, 是因为`var`是有构造函数的
// 有构造函数的类型作为返回值, 和C是不兼容的, 这导致 // 有构造函数的类型作为返回值, 和C是不兼容的, 这导致
// 类似 "extern "C" var fib" 的写法会得到编译错误 // 类似 "extern "C" var fib" 的写法会得到编译错误
extern "C" module_func_info* get() { NASAL_EXTERN module_func_info* get() {
return func_tbl; return func_tbl;
} }
``` ```

View File

@ -115,7 +115,7 @@ module_func_info func_tbl[] = {
} }
extern "C" module_func_info* get() { NASAL_EXTERN module_func_info* get() {
return fib_module::func_tbl; return fib_module::func_tbl;
} }

View File

@ -371,7 +371,7 @@ module_func_info func_tbl[] = {
{nullptr, nullptr} {nullptr, nullptr}
}; };
extern "C" module_func_info* get() { NASAL_EXTERN module_func_info* get() {
return func_tbl; return func_tbl;
} }

View File

@ -106,7 +106,7 @@ module_func_info func_tbl[] = {
{nullptr, nullptr} {nullptr, nullptr}
}; };
extern "C" module_func_info* get() { NASAL_EXTERN module_func_info* get() {
return func_tbl; return func_tbl;
} }

View File

@ -295,7 +295,7 @@ module_func_info func_tbl[] = {
{nullptr, nullptr} {nullptr, nullptr}
}; };
extern "C" module_func_info* get() { NASAL_EXTERN module_func_info* get() {
return func_tbl; return func_tbl;
} }

View File

@ -256,7 +256,7 @@ module_func_info func_tbl[] = {
{nullptr, nullptr} {nullptr, nullptr}
}; };
extern "C" module_func_info* get() { NASAL_EXTERN module_func_info* get() {
return func_tbl; return func_tbl;
} }

View File

@ -124,4 +124,13 @@ struct module_func_info {
// module function "get" type // module function "get" type
typedef module_func_info* (*get_func_ptr)(); typedef module_func_info* (*get_func_ptr)();
// avoid error loading function bug in MSVC version nasal.exe
#ifdef _MSC_VER
// and fuck MSVC again
#define NASAL_EXTERN extern "C" __declspec(dllexport)
#else
#define NASAL_EXTERN extern "C"
#endif
} }