简体   繁体   English

TDM-GCC-在Kernighan&Ritchie的Storage Allocator实施程序中对sbrk()的未定义引用

[英]TDM-GCC - undefined reference to sbrk() in Kernighan & Ritchie's Storage Allocator implementation program

I am trying to understand the storage allocator program shown in Kernighan and Ritchie's book "The C Programming Language, 2nd edition". 我试图理解Kernighan和Ritchie的书“ C编程语言,第二版”中显示的存储分配程序。 I think I understood most, but when I code the program in Windows 8.1 x86_64 with TDM GCC version 5.1.0 . 我想我最了解,但是当我在Windows 8.1 x86_64 with TDM GCC version 5.1.0编写程序时。 It outputs error undefined reference to 'sbrk' . 它输出错误的undefined reference to 'sbrk' These are my includes: 这些是我的包括:

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

I've searched quite a lot, but no other answers have helped me. 我已经搜索了很多,但是没有其他答案对我有帮助。 It is supposed to be inside unistd.h but it's not. 它应该在unistd.h内部,但事实并非如此。 Is it because, since it is a system call it cannot be found in Windows? 是否因为它是系统调用而无法在Windows中找到? What is wrong? 怎么了?

Yes, sbrk is a unix system call. 是的, sbrk是一个Unix系统调用。 It's not available on Windows. 在Windows上不可用。

(Side note: Functions themselves aren't inside headers; headers generally only contain declarations. The actual functions are in some library (libc in this case).) (注意:函数本身不在头文件内;头文件通常仅包含声明。实际函数在某些库(在本例中为libc)中。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM