If I have:
#define MAXLINE 5000
What type is MAXLINE understood to be? Should I assume it is an int
? Can I test it somehow?
Yes, you can assume it's an int
.
Well, actually all the other answers are correct. It's not C, it's just
a directive that tells the preprocessor to do some textual
substitutions, and as such it has no type. However, if you do not do any
funky things with it (like the ## preprocessor trick), you will
typically use MAXLINE
like some kind of constant, and the preprocessor
will replace it with 5000
which is indeed an explicit constant. And
constants do have type: 5000
is an int
. A constant written as a
decimal integer, with no suffix (like U or L), will be interpreted by
the compiler as an int
, long int
or unsigned long int
: the first
of these types that fits.
But this has of course nothing to do with the preprecessor. You could
rewrite your question as “what is the type of 5000
?”, with no
#define
.