From owner-freebsd-questions Tue Aug 14 6:32:56 2001 Delivered-To: freebsd-questions@freebsd.org Received: from comp04.prc.uic.edu (comp04.prc.uic.edu [128.248.230.104]) by hub.freebsd.org (Postfix) with SMTP id 7016737B405 for ; Tue, 14 Aug 2001 06:32:52 -0700 (PDT) (envelope-from lucas@comp04.prc.uic.edu) Received: (qmail 73823 invoked by uid 1000); 14 Aug 2001 13:33:12 -0000 Date: Tue, 14 Aug 2001 08:33:12 -0500 From: Lucas Bergman To: Wing Tim Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Programming Problem Message-ID: <20010814083312.C71404@comp04.prc.uic.edu> Reply-To: lucas@slb.to References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from twchim1@hotmail.com on Tue, Aug 14, 2001 at 03:35:28PM +0800 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > 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