Skip to main content
gamedev.net
🔒 Locked

Dereferencing Function Pointers

Started by Matt Calabrese Nov 1, 2002 at 6:20 PM 1 replies 300+ views
Original Post
Matt Calabrese
Matt Calabrese
I''ve always read that if you had a function pointer: void (*Blah)(); You had to call it by dereferencing the pointer first: (*Blah)(); However, I''ve noticed that in MSVC++ 6.0 my code compiles and runs fine just doing Blah(); Also, when initializing a function pointer, I always read that you had to explicitly reference the function: void (*Blah)() = &SomeFunction But in MSVC++ 6.0 I am able to do void (*Blah)() = SomeFunction; Are these actually standard, or are they just microsofts doing? I like the implicit refrencing and dereferencing, but I don''t want to do it if it won''t compile on other compilers. Thanks!
Jiia
Jiia
In MSVC, you can even

Blah = SomeFunction;

I''m not sure about the standardness.
Shannon Barber
Shannon Barber
Function pointers are automatically dereferenced.

You can test for standard-conforming code using Comaeu Computing''s Online Compiler.

Also, download Dev C++, which is a decent IDE for windows that uses gcc & mingw, which gives you another compiler to check code against. However, bare in mind that gcc implements a number of extentions.
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.