oh wait. (void*)1 is a void pointer with a value of 1. this pointer does not point to an integer of value 1. In fact, it doesn't point to anything at all..
I think he meant foo(&1).
A good compiler should reject that anyway.
(void*)1 could very well point to something, but for user applications, such an address is usually not within their range of valid choices to access, and attempting to do so will produce an access violation.
With modern systems (and virtual addressing), the thing at (void*)1 is probably not what you think it is anyway...
I meant foo((void*)1). The reason behind it is that a callback function in an API I'm using has a void* argument, and I want to check the value of the argument. I also was to set the value of this argument through another function.
For some reason I had the misconception that the "void pointer" data type itself could be any size, but I realized it's actually always the size of a pointer, or intptr_t defined in stdint.h. So I was asking the wrong question. Ignore this thread :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void callback(void* arg)
{
//arg would be 1, how would I check its value if <misconception>void* could be any size</misconception>
}
int main(int argc, char** argv)
{
//void on_keypress(void (*callback_func)(void*), void* value);
on_keypress(callback, (void*)1);
loop();
return 0;
}