Question about sbrk() 
Author Message
 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  
 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  
 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  
 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  
 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  
 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  
 
 [ 6 post ] 

 Relevant Pages 

1. mmap() vs sbrk() -- Question ??

2. brk(),sbrk() question

3. Problems with 2GB RAM on Linux and libc's sbrk

4. Problems with 2GB RAM on Linux and libc's sbrk

5. malloc and sbrk...what's the difference?

6. sbrk() in MS C 5.1 on MS-DOS

7. Looking for sbrk in qc2.5

8. sbrk() and malloc()

9. question question question

10. This is a biztalk question but probably an easy question for you C# guru's

11. Non-Programming Question... experience question mostly

12. Not C program question, historical question

 

 
Powered by phpBB® Forum Software