Skip to content

unpack解析错误 #69

Answered by TANSixu
novada0 asked this question in Q&A
Jan 10, 2023 · 4 comments · 1 reply
Discussion options

You must be logged in to vote

突然发现这是个非常好的问题!之前我们忘记了提示,就是pack会自动进行代码对齐。文档中提到:

且如果没有在fmt字符串中加入任何特殊首字符,会默认为@:

如果第一个字符不是其中之一,则假定为 '@' 。

所以这个fmt在calcsize中会得到32,就是因为自动对齐了。指定!为首字符后,不会进行对齐。如果有修改header的同学可以注意一下这个地方:自动对齐后的变量位置或者如何手动对齐。

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@TANSixu
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by TANSixu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
documentation Improvements or additions to documentation
2 participants