BUG: Typedef Type Causes C2275: Illegal Use of TypeLast reviewed: April 9, 1997Article ID: Q166513 |
The information in this article applies to:
SYMPTOMSUsing a typedef cast in the member initialization of a class may cause the following errors:
error C2275: 'test::run' : illegal use of this type as an expression error C2146: syntax error : missing ')' before identifier 'arg' error C2612: trailing '.*|->*' illegal in base/member initializer list error C2059: syntax error : ')' error C2143: syntax error : missing ';' before '{' fatal error C1004: unexpected end of file found RESOLUTIONUse the actual type rather then the typedef. For example, in the following sample use test::run rather than test_run. Or, use the functional notation test_run (arg) for type conversion instead of the cast notation. Another option is to initialize the member in the body of function.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
/* Compiler Options Needed : none */ class test { public: enum run{ one, two, three }; }; typedef test::run test_run; class test2 { test2(int); ~test2(); public: test_run testvalue; }; test2::test2(int arg):testvalue( (test_run) arg) {} //Causes error // test2::test2(int arg):testvalue( (test::run) arg) {} //WORKAROUND 1 // test2::test2(int arg):testvalue( test_run (arg)) {} //WORKAROUND 2 |
Keywords : CPPIss kbtool vcbuglist500 kbbuglist
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |