开发者

Is there a way to get an extern variable (or function) by name

开发者 https://www.devze.com 2023-01-13 14:48 出处:网络
I thought I read about a C standard library function recently that was able to return a pointer to any extern variable whose name was passed to it as a const char *.I think that it works via linker sy

I thought I read about a C standard library function recently that was able to return a pointer to any extern variable whose name was passed to it as a const char *. I think that it works via linker symbols开发者_如何转开发, if that helps.


You could be thinking of dlsym, which is not part of the C standard library but part of the POSIX API.


It depends on the system. dlsym has already been mentioned. Its Windows counterpart is GetProcAddress. In the latter case, the function needs to be not only external but exported.

0

精彩评论

暂无评论...
验证码 换一张
取 消