[英]check what type of pointer void* is pointing to in C
In my C program I am using void* pointers. 在我的C程序中,我使用的是void *指针。 Is there anyway to check in an if statement if the void* pointer is pointing to an int* or a char*?
无论如何,如果void *指针指向int *或char *,则检查if语句?
Nope. 不。 There is no run-time type information in C. A
void*
is just an address. C中没有运行时类型信息
void*
只是一个地址。 That's it. 而已。 It's completely up to the programmer to know / keep track of what information a
void*
points to. 这完全取决于程序员知道/跟踪
void*
指向的信息。
With more information about how/why you're using void*
, a workaround could possibly be suggested. 有关如何/为何使用
void*
更多信息,可能会建议解决方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.