2

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?

ildjarn
  • 62,044
  • 9
  • 127
  • 211
Dženan
  • 3,329
  • 3
  • 31
  • 44

1 Answers1

5

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++.

Community
  • 1
  • 1
Dženan
  • 3,329
  • 3
  • 31
  • 44