bilosikia's recent timeline updates
bilosikia

bilosikia

V2EX member #300795, joined on 2018-03-16 18:55:56 +08:00
Per bilosikia's settings, the topics list is hidden
Deals info, including closed deals, is not hidden
bilosikia's recent replies
Jul 2, 2020
Replied to a topic by phpcyy 程序员 一个关于 Raft 协议的疑问
1. 第一个是能保存成功的,1. leader 选出新的 leader 一定包含最新的 log 2. 前任 leader 的 log 谁着新任 leader 一起提交
2. 半数以上节点可用就行,A,B 挂了,只有 C 节点能当选新 leader
Dec 2, 2019
Replied to a topic by bilosikia 酷工作 字节跳动海量 HC 内推,急需大量人才
@joinmouse 北京
Dec 15, 2018
Replied to a topic by smdbh 程序员 C 下两个关于长度的问题
改成这样
printf("size %lu\n", sizeof(*pfn));

start sec 0x7fcf6ac007e2
stop sec 0x7fcf6ac00820
func1 0x7fcf6ac007e2
func2 0x7fcf6ac00801, 31
size 1
addr 0x7fcf6ac007e2
addr 0x7fcf6ac007e3
addr 0x7fcf6ac007e4
func is func1
Segmentation fault (core dumped)

对指针的加法运算是有指针指向的类型决定的,pfn ( pfn_test pfn = &__start_mysection; 这已经类型不匹配了)是指向的一个函数类型,sizeof(函数类型)= 1,
所以++ 只加了一

另外 c++是禁止对函数指针做加减法运算的
为什么 sizeof (函数类型)为一呢?
sizeof cannot be used with function types, incomplete types, or bit-field glvalues.
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2973 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 16ms · UTC 15:15 · PVG 23:15 · LAX 08:15 · JFK 11:15
♥ Do have faith in what you're doing.