Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual C++
C/C++ Build Errors
 Compiler Error C2275
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual C++ Concepts: Building a C/C++ Program
Compiler Error C2275

Error Message

'identifier' : illegal use of this type as an expression

An expression uses the -> operator with a typedef identifier.

The following sample generates C2275:

// C2275.cpp
typedef struct S {
    int mem;
} *S_t;
void func1( int *parm );
void func2() {
    func1( &S_t->mem );   // C2275, S_t is a typedef
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
This error can be misleading      Chris Adams   |   Edit   |   Show History
The C compiler also generates this error if you attempt to define a variable below the start of a function (legal in C99 but not earlier) if that variable declaration used a typedef:

my_struct foo* = func_which_returns_my_struct();

The solution is simple: move "my_struct foo*" to the top of the function and simply leave the assignment ("foo = func...").
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker