void * pointer convert problem.

K

Keith Thompson

Peter Nilsson said:
No, it's _almost_ any type. For instance, you generally can't assign a
function
pointer to a void pointer without a cast.

Strictly speaking, you can't do it with a cast (though many compilers
allow it). No conversions are defined between function pointers and
pointers to object or incomplete types.
 
C

Christopher Benson-Manica

Keith Thompson said:
of. The most straightforward way to comply with 6.5.2.3p5 is simply
to use layout rules that always guarantee the same layout for any
common initial subsequence.

Do you suppose that there is a particular reason the guarantee of
6.5.2.3p5 was not simply extended to all common initial subsequences?
If you're really concerned about conformance, you can declare (and not
bother to use) a union just to avoid the possibility, but I don't
think it's worth the effort.

Admittedly I was playing one of the more pedantic of the reindeer games.
 
M

Mark McIntyre

....
The u_long was defined in file:
/usr/include/linux/types.h

You don't seem to have included this header, and in addition its
nonstandard. Its best to avoid system-specific typedefs in example
code posted to CLC.
Mark McIntyre
 
E

Emmanuel Delahaye

Eric J.Hu a écrit :
I have following code, want do pointer convert. It always complain:

vcnvt.c: In function `main':
vcnvt.c:20: warning: dereferencing `void *' pointer

Sure. Why would you do that in the first place ? void* means, somehow,
'anonymous'. The size and fields are unknown. Dereferencencing is not
possible.
vcnvt.c:20: request for member `key' in something not a structure or union

ditto. You have a design error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,477
Latest member
ColumbusMa

Latest Threads

Top