On 4/16/07, Matthew Woehlke <mw_triad@xxxxxxxxxxxxxxxxxxxxx> wrote:
Anyway, I read somewhere that omitting the '&' is deprecated/unsupported for some language (i.e. might've been C++, or even Java) and/or standard and/or compiler. Because I agree with the sentiment (it's nice for readability also), I was hoping gcc could help enforce use of this syntax.
C++ requires the & on member function pointers, but not for regular function pointers. Last I checked, Java didn't have function pointers, though I haven't followed it. Warning for not using &, however, is impractical, even in C++. If you warn for taking the address of a regular function without using &, then the usual "Hello World for C++ will give a warning: #include <iostream> int main() { std::cout << "Hello World!" << std::endl; } Because endl is actually a function (http://www.roguewave.com/support/docs/sourcepro/edition9/html/stdlibref/basic-ostream.html#idx254). It's done that way so that (stateless) manipulators can be defined simply as normal functions (http://www.roguewave.com/support/docs/sourcepro/edition9/html/stdlibref/basic-ostream.html#idx254) . ~ Scott McMurray