Reputation: 3395
I am using VC2010, trying to compile some library written in C99 for Linux. The following line gives error C2275: 'uint8_t' : illegal use of this type as an expression
uint8_t * G = (uint8_t*)calloc(N ,sizeof(uint8_t));
subhint: stdint.h(21) : see declaration of 'uint8_t', and that line is:
typedef unsigned char uint8_t;
and then come the accumulated problems: error C2065: 'G' : undeclared identifier etc. What is illegal here?
Upvotes: 2
Views: 3015
Reputation: 3395
A similar question was already answered: error C2275 : illegal use of this type as an expression
Answer: When you name your source files *.c, MSVC assumes it's compiling C, which means C89. All function-local variables need to be declared at the beginning of your functions.
Workarounds include: - declaring/initializing all local variables at the beginning of your function - rename the source files to *.cpp or equivalent and compile as C++.
Upvotes: 5