Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
它似乎对 sbrk 的功能没有影响,但在 sbrk() 的文档中它说它需要一个 intptr_t 参数。
当将 int 类型作为参数传递时,它有效(或至少似乎有效)。
这是在常规 C 中。
intptr_t根据架构改变大小。int可能会也可能不会根据架构更改大小 - 也就是说,如果您使用的是 64 位,则intptr_t必须是 64 位,而int 可能是 32 位。
intptr_t
int
只要包含正确的标题,您就不会传递intto sbrk()。您传递的值将intptr_t根据 C 提升规则转换为。这些规则非常微妙,因此您至少应该知道它们存在并避免在极端情况下调用它们。
sbrk()
因此,当您传递的东西sbrk看起来像.intintptr_tintsbrk()
sbrk