Return to the archive index

Re: Memory allocation questions

To: Perry Harrington <pedward@sun4.apsoft.com>
Cc: linux-8086@vger.rutgers.edu
From: Ken Yap <ken@syd.dit.csiro.au>
Date: 	Mon, 14 Jul 1997 09:47:42 +1000
Newsgroups: linux.dev.8086

>	/* now, the "sizeof" command is a compiler preprocessor usually,
>		it looks in it's symbol table for the size of the
>		data item and replaces the call with a constant, this
>		works because structs can't be declared at runtime.
>		Now, Microsoft and Borland diverge on this point,
>		Borland treats it as a compiler command, and Microsoft
>		allows it to be used to determine the size of a chunk
>		of memory, which technically AFAIK is incorrect */
>
>	ptr=malloc(sizeof(struct foo));

Not true. The C preprocessor doesn't know anything about sizeof because
it doesn't know anything about data structures. The C preprocessor only
deals with # lines and substitution of macro names. I'm not sure what
you mean by the alleged difference between Borland and MS compilers.

From Unofficial Linux-8086 Mailing List Archive (ULMLA)
Maintained by Robert
Robert's Mailing List Archive Page

Archive created with babymail