Code:
#define smyType struct myType
struct myType {
double x;
double y;
} ;
int main(void)
{
smyType a,b;
printf("it works :D \n");
}
~
~
it works too, and it not require typedef
...but if the question is not "why we need typedef if you can use #define instead", but "why we need #define to define new types if you can use typedef instead?"
an the answer for YOUR question is:
* cos it's more easy to understand code wuthout too many #define's
* cos if you will migrate to c++ later your project can support namespaces with typedef (#define not)
* with #define it's quite easy to make mistake praticly not to solve by debug...
* and so on...
and now what about my question("why we need #define...")?
