You can't use 'sizeof' in a preprocessor test,
Ugh. Right. Didn't engage my brain.
You'd have to use a macro for the size of the hexchars array in the
first place; the appropriate thing would be to put MAXBASE in the
header and then use it as the explicit length of the hexchars array.
because the preprocessing is done before the compiling!
Well, no, it isn't, strictly speaking. "Preprocessing" is trans-
lation phase 4. The standard doesn't define "compiling", but I'd
consider it the entire translation process. You might consider, say,
translation phase 7 "compiling", but the term is open to interpre-
tation.
(I also note that the grammar in C90 Annex B implies that you *can*
use sizeof in a #if expression, as constant-expressions include
relational-expressions which can include unary-expressions which
include the sizeof operator applied to another unary-expression;
but this is just another case where the grammar is not the whole
story. The constraints in 6.8.1 include other restrictions.)
--
Michael Wojcik (e-mail address removed)
Thanatos, thanatos! The labourer, dropping his lever,
Hides a black letter close to his heart and goes,
Thanatos, thanatos, home for the day and for ever. -- George Barker