
Assigning "putchar" to a function pointer
Dear everyone,
is
int (*doprint)(int) = putchar;
safe? I seem to recall that putchar is usually implemented as a macro?
If that's the case, I would expect this to not be safe, but at the same
time I seem to have a extremely vague recollection of someone once
telling me that it's still safe.
Something about such a statement not referring to the macro when the
address is taken, but to a "real function" version? If I'm not making
any sense, please tell me. If I am, do I have the guarantee that such a
"real function implementation" will always exist in addition to a
possible macro implementation?
If I'm confusing putchar and getchar (which I know is usually a
macro), would it work for getchar?
Both libc-5.4.46 and glibc-2.2 on Linux are giving me the expected
results, without any warnings from "gcc -Wall -pedantic".
Many thanks in advance to anyone "in the know" !
Kind regards, Rene Herman
--