The information in this article applies to:
SYMPTOMSThe following error is generated when a statement of the form
is used to type cast a function pointer and make a call
simultaneously.
CAUSE
This is expected C++ compiler behavior. The sample code below explains
the problem in a more understandable way.
...
...
the following error message is generated:
Although the last statement appears to be typecasting the function "f" to funcptr, the compiler thinks it is declaring an object of name "f" of type funcptr and initializing it with the integer constant "1" equivalent to having
-or-
which makes the error message much more understandable.
RESOLUTIONThe way to the achieve the desired typecast is to add another set of parenthesis, for example
which resolves the confusion for the compiler, which thus treats the
typecast in the way it should.NOTE: Using a C++ style cast, such as (funcptr(f))(1), produces a syntax error. You must use C-style casting. Another method is to have a pointer explicitly bind a new name to the function, for example
and use:
MORE INFORMATIONThe sample below demonstrates the error and workarounds. Sample Code
Additional query words: 1.00 1.50 2.00 2.10 4.00 7.00 8.00 8.00c 9.00 9.10
Keywords : |
Last Reviewed: September 10, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |