I am doing a sample application where I have declared a struct:
// common.h
typedef struct MyStruct
{
int a;
}
//sample.h
#include "common.h"
int main()
{
MyStruct st;// getting error here
}
C2146: syntax error : missing ‘;’ before identifier
What are the possible reasons for this?
Two things:
First, you’re missing a semi-colon after the struct definition:
Not that this is still wrong. You will need to fix the other error.
Second, you should define the struct like this:
Alternatively, you can define it like this: