sizeof of struct field
Cesar Quiroz
quiroz at cs.rochester.edu
Fri Oct 27 08:04:06 AEST 1989
Under what conditions do you have
(1) access to the name of a struct,
(2) not an instance of the struct around ?
I cannot come up with an example where I would need sizeof of a
field, and not have an instance around. That, of course, is not an
argument. But, if it never happens, then there is no problem to be
fixed.
For the most part, I can imagine:
#include <defshere.h>
struct foo *
make_foo(...)
{
struct foo result = (struct foo *) malloc(sizeof(struct foo));
...
/* here I can use sizeof(result->slot) */
}
foobar
use_foo(struct foo one,...)
{
/* here I can use sizeof(one.slot) */
}
So, when would `sizeof( ((struct foo *)0)->slot )' be useful and not
one of the cases above be available?
--
Cesar Augusto Quiroz Gonzalez
Department of Computer Science
University of Rochester
Rochester, NY 14627
More information about the Comp.lang.c
mailing list