Re: typeless data [structures]
- From: SM Ryan <wyrmwif@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 31 May 2005 05:10:13 -0000
"Rob" <iouswuoibev@xxxxxxxxxxx> wrote:
# I seek to be able to store data in a static variable that has no
# specifically defined type/size. Or to put it another way, I wish to
# create a structure of data but without the ability to reference its
# subcomponents until I cast it to another predefined type.
C wants to know the size of things when allocates space for variables. One
way around that is to use pointers, because the compiler knows the size of
pointers. You can use a (void*) pointer as your variable and then cast it
to a pointer of whatever struct you want.
# struct {
#
# int : 0;
# long : 5;
# short : 2;
# } s;
#
# What does this do? Does it have anything to do with the functionality I
# am after? When I attempted to cast this struct it wouldn't allow me to;
# it gave the error "cannot convert from '' to <type_name>".
It's about using integers smaller than their natural size packed into a
structure.
--
SM Ryan http://www.rawbw.com/~wyrmwif/
You hate people.
But I love gatherings. Isn't it ironic.
.
- References:
- typeless data [structures]
- From: Rob
- typeless data [structures]
- Prev by Date: Re: Clear doubts regarding the C++ Runtime
- Next by Date: Re: size of pointer variables
- Previous by thread: Re: typeless data [structures]
- Next by thread: hashtable...squid
- Index(es):
Relevant Pages
|