简体   繁体   中英

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". I think I understood most, but when I code the program in Windows 8.1 x86_64 with TDM GCC version 5.1.0 . It outputs error 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. Is it because, since it is a system call it cannot be found in Windows? What is wrong?

Yes, sbrk is a unix system call. It's not available on 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).)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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