gpt4 book ai didi

c - TDM-GCC - 在 Kernighan & Ritchie 的存储分配器实现程序中未定义对 sbrk() 的引用

转载 作者:太空宇宙 更新时间:2023-11-04 08:02:38 26 4
gpt4 key购买 nike

我试图理解 Kernighan 和 Ritchie 的书“The C Programming Language, 2nd edition”中显示的存储分配器程序。我想我理解得最多,但是当我在 Windows 8.1 x86_64 和 TDM GCC 5.1.0 版 中编写程序时。它输出错误 undefined reference to 'sbrk'。这些是我的包括:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

我搜索了很多,但没有其他答案对我有帮助。它应该在 unistd.h 中,但实际上不是。是因为,因为它是一个系统调用,所以在 Windows 中找不到它吗?怎么了?

最佳答案

是的,sbrk 是一个 unix 系统调用。它在 Windows 上不可用。

(旁注:函数本身不在 header 内; header 通常只包含声明。实际函数在某个库中(在本例中为 libc)。)

关于c - TDM-GCC - 在 Kernighan & Ritchie 的存储分配器实现程序中未定义对 sbrk() 的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45040807/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com