我正在学习C程序但是我遇到了一些奇怪的行为,我期待一个结果,但是这样打印出两个结果
$ ./a.out
yes1 0x80000000
yes3 0x80000000
Run Code Online (Sandbox Code Playgroud)
怎么可能呢?
我无法理解结果.
OS : x86_64 Ubuntu Linux
C compiler : gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
gcc -O2 weird.c
#include <stdio.h>
int main() {
int i = 0x7fffffff;
int ii = 0x0000000f;
if ((i + 1) < ii)
printf ("yes1 %#x\n", i + 1);
if ((i + 1) == ii)
printf ("yes2 %#x\n", i + 1);
if ((i + 1) > ii)
printf ("yes3 %#x\n", i + 1);
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我目前正在查看stdatomic.hubuntu linux中的头文件。和 中的逗号
有什么用?
这不需要什么吗?(void)0__typeof__ ((void)0, *__atomic_store_ptr)
#define atomic_store_explicit(PTR, VAL, MO) \
__extension__ \
({ \
__auto_type __atomic_store_ptr = (PTR); \
__typeof__ ((void)0, *__atomic_store_ptr) __atomic_store_tmp = (VAL); \
__atomic_store (__atomic_store_ptr, &__atomic_store_tmp, (MO)); \
})
Run Code Online (Sandbox Code Playgroud) 我正在阅读HashMap的get功能,但我K在源代码中找不到类型参数.
为什么K特征绑定存在于where子句中,而不存在于函数签名中?
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
where K: Borrow<Q>,
Q: Hash + Eq
{
self.search(k).map(|bucket| bucket.into_refs().1)
}
Run Code Online (Sandbox Code Playgroud)