|
Author |
Message |
Leo Wo #1 / 6
|
 Question about sbrk()
I can't compile the malloc program given in Section 8.7 of K&R. I have included header file unistd.h but gcc told me that sbrk() is not defined.
|
Thu, 03 Feb 2005 23:23:05 GMT |
|
 |
Mark McIntyr #2 / 6
|
 Question about sbrk()
On 18 Aug 2002 08:23:05 -0700, in comp.lang.c , Quote:
>I can't compile the malloc program given in Section 8.7 of K&R. I have >included header file unistd.h but gcc told me that sbrk() is not >defined.
if ch 8 is the one I think it is, then this is offtopic in CLC since it relates to Unix specific stuff. However I suspect that the answer to your question is that K&R wrote for one flavour of Unix, and you're using a different one, linux at a guess. Unices are not all the same and nor are their compiler environments. -- Mark McIntyre CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html> CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
|
Fri, 04 Feb 2005 06:21:29 GMT |
|
 |
Kevin Easto #3 / 6
|
 Question about sbrk()
Quote: > On 18 Aug 2002 08:23:05 -0700, in comp.lang.c ,
>>I can't compile the malloc program given in Section 8.7 of K&R. I have >>included header file unistd.h but gcc told me that sbrk() is not >>defined. > if ch 8 is the one I think it is, then this is offtopic in CLC since > it relates to Unix specific stuff. However I suspect that the answer > to your question is that K&R wrote for one flavour of Unix, and you're > using a different one, linux at a guess. Unices are not all the same > and nor are their compiler environments.
sbrk is defined on linux, at least in glibc2.2.
|
Fri, 04 Feb 2005 09:08:34 GMT |
|
 |
m #4 / 6
|
 Question about sbrk()
Quote:
> I can't compile the malloc program given in Section 8.7 of K&R. I have > included header file unistd.h but gcc told me that sbrk() is not > defined.
Perhaps you intended to use strpbrk() (defined in string.h) ? Otherwise, neither the function nor the header (unistd.h) are standard C. Cheers, Matt
|
Fri, 04 Feb 2005 14:01:53 GMT |
|
 |
Csab #5 / 6
|
 Question about sbrk()
doesn't sound like I. Must be a human: Quote:
>> I can't compile the malloc program given in Section 8.7 of K&R. I >> have included header file unistd.h but gcc told me that sbrk() is not >> defined.
find /usr/include -name '*.h' | xargs grep sbrk Quote: > Perhaps you intended to use strpbrk() (defined in string.h) ?
I doubt it. Implementing malloc() using strpbrk() is left as an exercise for the reader :-) -- A .sig ! A .sig ! My kingdom for a .sig !
|
Sat, 05 Feb 2005 07:02:18 GMT |
|
 |
Zoran Cutur #6 / 6
|
 Question about sbrk()
Quote:
>> On 18 Aug 2002 08:23:05 -0700, in comp.lang.c ,
>>>I can't compile the malloc program given in Section 8.7 of K&R. I have >>>included header file unistd.h but gcc told me that sbrk() is not >>>defined. >> if ch 8 is the one I think it is, then this is offtopic in CLC since >> it relates to Unix specific stuff. However I suspect that the answer >> to your question is that K&R wrote for one flavour of Unix, and you're >> using a different one, linux at a guess. Unices are not all the same >> and nor are their compiler environments. > sbrk is defined on linux, at least in glibc2.2.
declared in unistd.h AFAICT. So it may or may not be Linux or else, it may also be a Winloose gcc that complaines, but than it would probably have had problems with the header-include prior to the functions use. --
"LISP is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days." -- Eric S. Raymond
|
Sat, 05 Feb 2005 16:58:32 GMT |
|
|
|