Assigning "putchar" to a function pointer 
Author Message
 Assigning "putchar" to a function pointer

Dear everyone,


        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

Sat, 20 Sep 2003 07:20:43 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Assigning "putchar" to a function pointer

2. "function pointers" question

3. passing "function pointer"

4. Passing "callback" function to a function

5. Is "if (!pointer)" as portable as "if (pointer == NULL)"

6. "long pointer" vs "pointer"

7. remove() vrs fopen("""w")

8. Displaying binary data as ascii "1"'s and "0"'s

9. Looking for "Shroud"/"Obfus"

10. ""help with TSR""

11. Parse trees and "("")"

12. Error "free"-ing "malloc"-ed memory


Powered by phpBB® Forum Software