I am currently using a C++ IDE for something that will need to work on C, and wanted to make sure that I won\'t have problems with this later on. After making the struct bel
In both C and C++, the example construct is modestly pointless:
typedef struct test {
int a;
int b;
};
In C, this says there is a type struct test with the two integers as content. If there was a name between the close brace '}' and the semi-colon ';', then you would get some benefit from the keyword typedef; as it stands, the keyword typedef is redundant, and (if set fussy enough), GCC will warn you about it.
In C++, this says there is a type struct test; further, in C++, it creates a type test too (which does not happen in C). The keyword typedef can still be left out and the same result will be achieved.
The syntax is legal; it is not useful, that's all. The keyword typedef can be omitted without changing the program's meaning in the slightest.
You can do:
typedef struct test {
int a;
int b;
} test;
Now, in both C and C++, you have a type struct test and an alias for it test.