mdh said:
Sorry, am not familiar with the notion of "conforming mode". Will look
it up, thanks.
(The quoting level was messed up; I think I've corrected it.)
Compilers commonly have options (command-line or otherwise) that make
them behave differently. A compiler will typically have a set of
options that cause it to behave as a conforming C compiler; other sets
of options may enable extensions that, while perhaps useful, can break
conforming code.
"ungetch" happens to be the name of a non-standard function provide by
the curses or ncurses library, but as far as the C standard is
concerned, it's just another identifier. A conforming C compiler must
allow you to define "ungetch" for yourself in any way you like, as
long as you don't have a #include for some non-standard header that
defines it. A compiler that gives you trouble because you've used
that identifier is not conforming. There *should* be a way to tell
the compiler to behave in a conforming manner; it may or may not be
the default.
On the other hand, avoiding such identifiers isn't a bad idea. If you
define your own ungetch() function, and later decide to have your
program use the curses library, you're going to have problems. But
nobody can reasonably be expected to keep track of all the identifiers
declared by every third-party library in existence, and the C standard
is defined in such a way that you don't have to.
<OT>
Something like C++'s namespaces would make this easier. Rather than
ungetch(), curses could define curses::ungetch(), and your own
my_library::ungetch() wouldn't conflict with it. You'd just have to
ensure that each namespace has a unique name, not each identifier in
every library. A common workaround in C is to use a common prefix as
part of each identifier, but that can get very ugly very quickly.
</OT>