LeTubs <> scribbled the following
on comp.lang.c:
> Hi All
> I'm just checking if my assumptions are correct
> If I have the following line
> #define CLIENT_MSG_HELLO 9
> I know the define will be stored in a memory location, but
> what will it be stored as ie short, int, unisigned int ?
> Are there any general rules or is it platform/OS dependant?
You have a misconception. Macros (i.e. #defines) aren't stored. All they
are is a formal version of search-and-replace. When the compiler creates
the object file, which is then linked into an executable, there is no
sign of the #define anywhere. It has been replaced by its expansion and
the situation is the same as if the expansion was there all along.
In other words, given your macro definition above, CLIENT_MSG_HELLO is
*completely identical* to the number 9. The storage rules for this
number 9 are the same as for any other number 9 - it depends on the way
it is used. If you assign it into a short, it's stored as a short. If
you assign it into an int, it's stored as an int. As a value by itself,
it's stored as an int.
These are general rules, because they are in fact defined by the
standard. So it does not depend on the platform or OS.
--
/-- Joona Palaste () ------------- Finland --------\
\--
http://www.helsinki.fi/~palaste --------------------- rules! --------/
"That's no raisin - it's an ALIEN!"
- Tourist in MTV's Oddities