Is it still common practice to use type aliases (INT, PCHAR etc).
It depends what those aliases are for. INT instead of int makes
no sense, neither does PCHAR instead of char*. However, there are
probably some places where WORD is bettern than unsigned short
(like in a functional style cast) or DWORD instead of unsigned long
(for similar reasons). [you can see I've been working in Windows]
I thought the use of INT was to specify a minimum size, eg 32 bits, so
you know it is safe to use this type with values in the range
+/-2**31. Code needs to assume a minimum size, but it shouldn't need
to assume a maximum, or exact, size. INT was probably useful years
ago, I am not sure now.
Why this has to be done for chars or (FFS) bools I really don't know.
These things are never going to change size.
The use of WORD to specify exactly 16 bits (as opposed to SHORT to say
*at least* 16 bits) is usually either unnecessary or dodgy. eg people
sometimes create structures using BYTE, WORD, DWORD then assume they
know the exact layout of the bytes in memory, usually just to allow
lazy coding.
WORD has its uses, eg if you are directly accessing memory mapped
hardware registers, but most times it is abused.
Uh... How do 16-bit ints play into the type aliasing?
I thought that was the main point.
You write code with INT defined as int, assuming it is a 32 bit int.
If you ever need to compile with a compiler that uses 16 bit ints, you
redefine INT as long for that specific compiler.
Isn't that the basic reason it is done?
But unless you are targeting a machine from the late 70's, or some
really specialised embedded system, this isn't realy an issue anymore
is it?
No, but ask the reverse question.
If you mean does the aliasing do any harm, well I'd say it does. It is
ugly and it stops syntax highlighting working, to name two. If it has
absolutely no upside, then any downside is enough to say you shouldn't
use it.