Date: Tue, 14 Aug 2001 08:33:12 -0500 From: Lucas Bergman <lucas@slb.to> To: Wing Tim <twchim1@hotmail.com> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Programming Problem Message-ID: <20010814083312.C71404@comp04.prc.uic.edu> In-Reply-To: <F164scroFsBuV9yFo0X00009d6c@hotmail.com>; from twchim1@hotmail.com on Tue, Aug 14, 2001 at 03:35:28PM %2B0800 References: <F164scroFsBuV9yFo0X00009d6c@hotmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> I have copied the "malloc.h" header file (without any change) from
> the directory "/usr/src/sys/sys" to a newly created directory. Then
> I write a short program "test.c" and place in the same
> directory. The program is as follows:
This is a strange experiment you're conducting, but I'll play along.
> --------------------
> #include "malloc.h"
>
> main ()
> {
> printf("Test!\n");
> }
> --------------------
Okay, I have to interject here:
(1) You used printf() without including stdio.h.
(2) You let main() be implicitly declared as returning 'int'.
(3) You didn't return an 'int' from main().
Also, I should say that malloc.h is deprecated for use in user code.
For malloc() et. al., include stdlib.h instead.
> However, when I compiled it using "gcc s.c", I surprisingly found that the
> following errors occur:
> -------------------------------------------
> # gcc test.c
> In file included from test.c:1:
> malloc.h:59: syntax error before 'int64_t'
> malloc.h:61: syntax error before 'u_long'
> malloc.h:63: syntax error before 'u_short'
> malloc.h:92: syntax error before 'u_short'
> malloc.h:103: syntax error before 'caddr_t'
> -------------------------------------------
> Do you know what's the matter? Is that the original header files in
> FreeBSD 4.2 Release have bugs?
No. If you include sys/types.h before malloc.h, everything is fine.
But, pay attention to what I said above and don't do that.
> What should I do if I still want to make use of these header files
> to write programs?
Please don't. Use stdlib.h and other files mentioned in the ISO
standard whenever possible.
Lucas
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010814083312.C71404>
