I have a problem with compiling C application, the errors that are shown are senseless. I don’t know where to start looking for a solution.
Here is the code:
static char* FilterCreate(
void* arg,
const char* const* key_array, const size_t* key_length_array,
int num_keys,
size_t* filter_length) {
*filter_length = 4;
char* result = malloc(4); // error: error C2143: syntax error : missing ';' before 'type' C:\Projects\myleveldb\db\c_test.c
memcpy(result, "fake", 4);
return result;
}
Here is the fullscreen screenshot:

What might cause such error?
You are compiling C code with a C89/90 compiler.
In classic C (C89/90) it is illegal to declare variables in the middle of a block. All variables must be declared at the beginning of a block.
Once you started to write statements, like
*filter_length = 4, it means that you are done with declarations. You are no longer allowed to introduce variable declarations in this block. Move your declaration higher and the code will compile.In C language declarations are not statements (as opposed to C++ where declaration is just a form of statement). And in C89/90 the grammar for compound statement is:
meaning that all declarations have to come first, at the beginning of the block.
Note that in C99 declarations are not statements either. But the grammar for compound statement has been changed to:
which is why you can interleave declarations and statements in C99.