gpt4 book ai didi

c - libc_hidden_​​builtin_def (strspn) 是什么意思?

转载 作者:太空宇宙 更新时间:2023-11-04 01:31:45 24 4
gpt4 key购买 nike

libc_hidden_builtin_def (strspn)

我在 glibc-2.18/string/strspn.c 中找到了上面的代码。谁能解释一下这是什么意思。这对其余代码重要吗?以下是文件 strspn.c 的内容:

#include <string.h>

#undef strspn

/* Return the length of the maximum initial segment
of S which contains only characters in ACCEPT. */
size_t strspn (s, accept) const char *s; const char *accept; {
const char *p;
const char *a;
size_t count = 0;

for (p = s; *p != '\0'; ++p) {
for (a = accept; *a != '\0'; ++a) {
if (*p == *a)
break;
if (*a == '\0')
return count;
else
++count;
}
}

return count;
}
libc_hidden_builtin_def (strspn)

最佳答案

Can someone explain what this mean.

它是一个#defined 宏,在构建(非共享)libc.a 时扩展为空,并且:

extern __typeof (strcspn) __EI_strcspn __asm__("" "strcspn");
extern __typeof (strcspn) __EI_strcspn __attribute__((alias ("" "__GI_strcspn")));

在编译 libc.so.6 时。

它所做的是定义一个符号别名 __GI_strcspn,它与 strcspn 具有相同的值,但不会从 libc.so.6 中导出(即它是一个内部符号)。

Is this important to rest of the code?

是的:libc.so.6 中的其他代码可能会调用此符号,而无需将其插入例如LD_PRELOADED 库。

关于c - libc_hidden_​​builtin_def (strspn) 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21323443/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com