Re: void * pointer convert problem.
- From: "nelu" <tandauioan@xxxxxxxxx>
- Date: 30 Dec 2005 12:06:48 -0800
Christopher Benson-Manica wrote:
> I don't believe that's a portable assumption. The structures could
> have different padding bits, so unless key is the first element (in
> which case all is well, as structs can always be converted into a
> pointer to their first element),
So if I have:
struct s1 {
int id;
char *name;
int year;
};
struct s2 {
int id;
char *name;
int year;
time_t tstamp;
};
....
void *p;
struct s2 b;
....
p=&b;
((struct s1 *)p)->year=2000;
....
the last assignment may not be portable?
I may be wrong, but I think GTK+ is doing something similar.
.
- Follow-Ups:
- Re: void * pointer convert problem.
- From: Christopher Benson-Manica
- Re: void * pointer convert problem.
- References:
- void * pointer convert problem.
- From: Eric J.Hu
- Re: void * pointer convert problem.
- From: Christopher Benson-Manica
- Re: void * pointer convert problem.
- From: Eric J.Hu
- Re: void * pointer convert problem.
- From: tmp123
- Re: void * pointer convert problem.
- From: Christopher Benson-Manica
- void * pointer convert problem.
- Prev by Date: Re: Printf question.
- Next by Date: Re: exponentiation operator (lack of)
- Previous by thread: Re: void * pointer convert problem.
- Next by thread: Re: void * pointer convert problem.
- Index(es):
Relevant Pages
|