function that returns value from dlsym()?

烂漫一生 提交于 2019-12-04 18:15:59

The C standard does not actually define behaviour for converting to and from function pointers. Explanations vary as to why; the most common being that not all architectures implement function pointers as simple pointers to data. On some architectures, functions may reside in an entirely different segment of memory that is unaddressable using a pointer to void.

The “recommended” way to use dlsym is:

 LSError (*LS_DiscPrinter_ReleaseExclusiveUse)(LS_DiscPrinterHandle);

 *(void **)&LS_DiscPrinter_ReleaseExclusiveUse = dlsym("LS_DiscPrinter_ReleaseExclusiveUse");

Read the rationale and example on the POSIX page for dlsym for more information.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!