关于glibc strlen中string.hin 的实现我有两个问题.
该实现使用带有"洞"的幻数.我无法理解这是如何工作的.有人可以帮我理解这个片段:
size_t
strlen (const char *str)
{
const char *char_ptr;
const unsigned long int *longword_ptr;
unsigned long int longword, himagic, lomagic;
/* Handle the first few characters by reading one character at a time.
Do this until CHAR_PTR is aligned on a longword boundary. */
for (char_ptr = str; ((unsigned long int) char_ptr
& (sizeof (longword) - 1)) != 0;
++char_ptr)
if (*char_ptr == '\0')
return char_ptr - str;
/* All these elucidatory comments …Run Code Online (Sandbox Code Playgroud)我是Java的新手.我有一个接口,有一些我需要实现的方法.在界面内部,有一个类我需要访问的枚举.
它看起来像这样:
public interface Operations{
//some function names that I have to implement
public static enum ErrorCodes{
BADFD;
NOFILE;
ISDIR;
private ErrorCode{
}
}
}
Run Code Online (Sandbox Code Playgroud)
在我的实现中,当我尝试访问ErrorCodes.BADFD它时给了我错误.我不知道访问它的正确方法.另外,什么是空调private ErrorCode{}.它是构造函数吗?它有什么作用?
编辑:在枚举名称中添加了大写的"o"