Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tb_dynamic_init应该设法返回错误信息 #256

Open
jingkaimori opened this issue Apr 13, 2024 · 1 comment
Open

tb_dynamic_init应该设法返回错误信息 #256

jingkaimori opened this issue Apr 13, 2024 · 1 comment

Comments

@jingkaimori
Copy link

你在什么场景下需要该功能?

目前tb_dynamic_init在posix上会检查dlerror并丢弃其返回值,而dlerror第二次调用时一定返回空指针;因此如果加载动态链接库时出现错误,无法通过tbox或者系统API获取错误信息。

描述可能的解决方案

tb_dynamic_init以结构体的形式,打包返回符号表句柄和错误消息指针;

// definiton
typedef struct {
    tb_dynamic_ref_t library;
    tb_char_t* msg;
}tb_dynamic_init_result_t;
tb_dynamic_init_result_t tb_dynamic_init(const tb_char_t* name);

// usage
tb_dynamic_init_result_t res = tb_dynamic_init("/path/to/library");

描述你认为的候选方案

tb_dynamic_init添加指针参数

// definiton
tb_dynamic_ref_t tb_dynamic_init(const tb_char_t* name, tb_char_t** msg);

// usage
tb_char_t *msg=tb_null;
tb_dynamic_ref_t res = tb_dynamic_init("/path/to/library", msg);

其他信息

dlerror(3p)

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: tb_dynamic_init should try to return an error message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants