I need to compile some code originally written in C++ in C for a specific platform. I am having problem with the line below which is attempting to set p to the start of outputdata as below.
I am getting a compiler error error C2143: syntax error : missing ‘;’ before ‘type’
How do I need to change this to compile in C?
size_t example_function(unsigned char** outputdata, size_t *output_length)
{
*outputdata = (unsigned char*)malloc(20);
unsigned char* p = *outputdata;
return 0;
}
I’m guessing that you are using the Visual C++ compiler to compile this. This compiler only supports C90 (aka C89), so you will need to put declarations before any other statements in any block.
I am assuming that you have (directly or indirectly) included
<stdlib.h>for definitions ofsize_tandmallocotherwise you would probably have a different error.