Barry Schwarz said:
Barry Schwarz said:
const char ASCII_to_Scancode[256]
[max_number_of_scancodes_per_character] = {
{0x45,0xF0,0x45,0x00},
{0x45,0xF0,0x45,0x00},
Or better yet, don't use global variables
This isn't a variable, it is a lookup table. There is no reason for it
to change during the run of the program. That is one of the cases in
which the use of a global array is entirely justifiable.
The standard refers the such declared objects as variables fairly
often. It seems an appropriate use of the term even if the comment is
not.
No, it doesn't. The standard uses the term "variable" to refer to
declared objects only in a handful of places in non-normative text;
none of those are const-qualified.
I wasn't aware that a term had to appear in the normative part of the
text in order to indicate it was acceptable in discussions about the
language.
It doesn't, and I didn't mean to imply that it does.
If so, then sections 7.6 and F.8.1 are twice as many as
needed to satisfy that condition.
7.6 and F.8.1 refer to floating-point status flags and floating-point
control modes, not C objects, as "system variables".
(BTW, by my count there are 8 uses of the noun "variable" in the C99
standard referring to C objects, all of them in non-normative text.
I won't dispute whether this qualifies as "fairly often".)
Since a const-qualified object can also be volatile-qualified
(6.2.5-26 and 6.5.15-8), it seems apparent that const does not mean
the value of the object can never change. So even if the object
cannot be called a variable, it certainly can be variable. Objections
to the noun seem somewhat artificial.
My only objection to the term "variable" is that it's imprecise.
A declared object that's not const qualified is, I'd say,
unambiguously a "variable", and I have no problem calling it that.
Any other object might or might not be, depending on who's defining
the term.
In this particular case, I personally wouldn't refer to
ASCII_to_Scancode as a "variable", simply because it's const-qualified
and therefore does not vary (in spite of the old "constants aren't,
variables won't" joke).
But if you want to call it a variable, the standard offers me no
basis to refute you.