contents in a Void pointer 
Author Message
 contents in a Void pointer

I want to know is there any function exist in C,to know what is the type
of the content in a void pointer at runtime.
 i want both the fundamental data types and also the derived data types.

thanks in advance
vector



Sun, 27 Jun 2004 21:54:36 GMT  
 contents in a Void pointer

Quote:
> I want to know is there any function exist in C,to know what is the type
> of the content in a void pointer at runtime.
>  i want both the fundamental data types and also the derived data types.

Impossible. The standard C type system is an entirely compile-time
concept. The compiled code, at run-time, deals straight with bits, bytes
and memory accesses. No type information whatsoever is stored in memory
unless you yourself write C code to do that.

--

| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste       W++ B OP+                     |
\----------------------------------------- Finland rules! ------------/
"I am looking for myself. Have you seen me somewhere?"
   - Anon



Sun, 27 Jun 2004 21:56:50 GMT  
 contents in a Void pointer


Quote:
> I want to know is there any function exist in C,to know what is the type
> of the content in a void pointer at runtime.

There is no such function in C.

Quote:
>  i want both the fundamental data types and also the derived data types.

Twice disappointed.

You have to remember it for yourself (wholesale, or not, as you choose).

--
Chris "allusive" Dollin
C FAQs at: http://www.faqs.org/faqs/by-newsgroup/comp/comp.lang.c.html



Sun, 27 Jun 2004 21:58:48 GMT  
 contents in a Void pointer
On 9 Jan, in article


Quote:
>I want to know is there any function exist in C,to know what is the type
>of the content in a void pointer at runtime.

The type of the value stored in a void * object is void *. void * has the
property that you can convert a pointer to any type (except pointers to
functions) to void * and back again to the original type and you get
back the original value. But there are clear conversion steps involved,
void * does not store pointers of other types. It is up to you to specify
the apropriate type in the source code when converting back from void *.

Quote:
> i want both the fundamental data types and also the derived data types.

Then you will have to make a record of them yourself and pass that
around to whatever code needs it.

--
-----------------------------------------


-----------------------------------------



Sun, 27 Jun 2004 22:27:55 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. copying the content of a void-pointer to another void-pointer?

2. void pointer (void *) : how to determine type?

3. from void (void*) to void (_cdecl*) (void*)

4. Casting function pointer to void pointer

5. problem with pointer to pointer to void

6. pointers to functions and pointers to void.

7. pointer arithmetic with a pointer to void

8. Can void-pointers be casted to function-pointers?

9. Pointer-arithmatic and void pointers

10. casting void pointer to be a pointer to a function

11. casting void pointer to be a pointer to a function

12. Viewing content of void* in Debugg

 

 
Powered by phpBB® Forum Software