Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!brl-tgr!ron
From: ron@brl-tgr.ARPA (Ron Natalie )
Newsgroups: net.lang.c
Subject: Re: A useful construct for C ?
Message-ID: <8095@brl-tgr.ARPA>
Date: Wed, 6-Feb-85 16:32:44 EST
Article-I.D.: brl-tgr.8095
Posted: Wed Feb  6 16:32:44 1985
Date-Received: Sun, 10-Feb-85 04:07:15 EST
References: <389@lll-crg.ARPA>
Organization: Ballistic Research Lab
Lines: 25


> I would like to sample the community on a possibly useful construct
> 	typeof(foo)
> which is the type of expression foo.  It is similar in utility to sizeof().
> 
>	....
>
> It would be nice to be able to say:
> 	int *foo;
> 	foo = (typeof(foo))malloc(sizeof(*foo) * nelts);
> 

Well first, would the C standard group's (void *)'s help here?

Actually, MALLOC really should know what alignment requirement is
required.  Right now it just takes the least common multiple of
all data types.  Should a similar builtin function (I'll use a
silly name here to avoid confusion:

	foo = (typeof foo) malloc(sizeof(*foo)*nelts, rons_typeof foo);

Where rons_typeof would yield something like an enum that could be checked
for in the Malloc routine.

-Ron