Archived

This topic is now archived and is closed to further replies.

Matt Calabrese

Dereferencing Function Pointers

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites