Compiler Errors C2200 throu ...


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 :


Community Content

Chris Adams
This error can be misleading
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 :

Page view tracker