dkimmel7
dkimmel7

Reputation: 53

check what type of pointer void* is pointing to in C

In my C program I am using void* pointers. Is there anyway to check in an if statement if the void* pointer is pointing to an int* or a char*?

Upvotes: 2

Views: 236

Answers (1)

Jonathon Reinhart
Jonathon Reinhart

Reputation: 137398

Nope. There is no run-time type information in C. A void* is just an address. That's it. It's completely up to the programmer to know / keep track of what information a void* points to.

With more information about how/why you're using void*, a workaround could possibly be suggested.

Upvotes: 8

Related Questions