Victor said:
Ioannis Vranos wrote:
Ioannis Vranos wrote:
I think I read somewhere that #define constants in the style
#define SOMETHING 6
are evaluated to long or unsigned long, depending on the situation
and not int.
... Is that true?
I don't know whether it's true that you read that nonsense somewhere
or whether you dreamed it. I know that an integral literal has the
type 'int' if it fits in it, and if it doesn't, it has type long int,
unless overridden by a suffix (absent in your example). This all is
defined in [lex.icon]/2.
My mistake. It is about the "identifier" of the macro expressions
defined identifier
and
defined ( identifier)
Errata for K&R2 page 232 (from
http://www-db-out.research.bell-labs.com/cm/cs/cbook/2ediffs.html):\
232(§A12.5): The result of the defined operator is not replaced
literally by 0L or 1L, nor are undefined names literally by 0L, but just
by plain 0 or 1. However, the constant expression is nevertheless
evaluated as if these and other constants appearing have long or
unsigned long type.