man page 中写到:要在dlsym()中使用RTLD_NEXT需要在引入dlfcn.h前定义_GNU_SOURCE:
NOTES
The symbols RTLD_DEFAULT and RTLD_NEXT are defined by <dlfcn.h> only when _GNU_SOURCE was defined before including it.
奇怪的是我怎么测试都不行(FC4),索性把GNU_SOURCE, _GNU_SOURCE, __GNU_SOURCE都定义了,错误依旧:
inter.c:21: error: 'RTLD_NEXT' undeclared (first use in this function)
于是打开/usr/include/dlfcn.h直接看代码,发现这样一段:
#ifdef __USE_GNU
/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT
the run-time address of the symbol called NAME in the next shared
object is returned. The "next" relation is defined by the order
the shared objects were loaded. */
# define RTLD_NEXT ((void *) -1l)
/* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT
the run-time address of the symbol called NAME in the global scope
is returned. */
# define RTLD_DEFAULT ((void *) 0)
manpage难道会出现这么低级的错误?还是我没有找到问题的真正所在(毕竟很少见__USE_GNU这样的macro)?
没有评论:
发表评论