V
Vladimir Oka
Christian said:Hi,
what is the difference between a "#define" and typedef?
A "#define" is handled by the preprocessor and serves as a name
substitude whereas "typedef" is a declaration of a new data type
based on an exisiting one and handled by a compiler.
So, actually both things are equivalent?
Well, you answered this yourself above. Obviously different beasts
altogether.
Or are there any special cases where it makes a difference
which specifier is used?
What if someone decides to use `#undef` on your neatly `#define`d new
type. And then `#define`s it as something altogether different. In an
`#include`d file just below yours. Without telling you.
It may be cumbersome to `#define` multiline types (think `struct` and
`union`).
I'm sure someone will come along and point other differences, and
pitfalls of using `#define` for defining new types.