======================= Cover sheet starts here ======================== Document Number: WG14 N___/X3J11 __-___ C9X Revision Proposal ===================== Title: printf function pointers Author: David R. Tribble Author Affiliation: Self Postal Address: 6004 Cave River Dr. Plano, TX 75093-6951 USA E-mail Address: dtribble@technologist.com david.tribble@beasys.com dtribble@flash.net Web: http://www.flash.net/~dtribble Telephone Number: +1 972 738 6125, 15:00-00:00 UT +1 972 964 1720, 00:00-03:00 UT Fax Number: +1 972 738 6111 Sponsor: ________________________________________ Date: 1999-02-08 Revision: 2 Proposal Category: __ Editorial change/non-normative contribution __ Correction X_ New feature __ Addition to obsolescent feature list __ Addition to Future Directions __ Other (please specify) _____________________________ Area of Standard Affected: __ Environment __ Language __ Preprocessor X_ Library __ Macro/typedef/tag name X_ Function __ Header __ Other (please specify) _____________________________ Prior Art: None known. Target Audience: Users of printf() and scanf() Related Documents (if any): None Proposal Attached: X_ Yes __ No, but what's your interest? Abstract: The addition of a format specifier for writing and reading function pointer values. ======================= Cover sheet ends here ========================== DESCRIPTION This proposal describes the addition of a printf/scanf format specifier to be used for writing and reading function pointer values. This would be especially useful for debugging. This need arises in C because function pointers might not be convertible to (data) pointers to void (see 6.2.5p27). PROPOSAL (Section numbers are based on the C9X draft WG14/N843 dated 1998-08-03.) Change 7.19.6.1p7 by adding the bracketed text: j Specifies that a following d, i, o, u, x, or X conversion specifier applies to an intmax_t or uintmax_t argument; or that a following n conversion specifier applies to a pointer to an intmax_t argument{; or that a following p conversion specifier applies to a pointer to a function argument}. Change 7.19.6.1p8 by adding the bracketed text: p The argument shall be a pointer to void{, or if the format specifier was preceded by a j modifier, the argument shall be a pointer to a function of type void(void)}. The value of the pointer is converted to a sequence of printable characters, in an implementation-defined manner. Change 7.19.6.2p11 by adding the bracketed text: j Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type intmax_t or uintmax_t{; or that a following p conversion specifier applies to an argument with pointer to function type}. Change 7.19.6.2p12 by adding the bracketed text: p Matches an implementation-defined set of sequences, which should be the same as the set of sequences that may be produced by the %p {or %jp} conversion of the fprintf function. The corresponding argument shall be a pointer to a pointer to void{, or if the format specifier was preceded by a j modifier, the argument shall be a pointer to a pointer to a function of type void(void)}. The interpretation of the input item is implementation-defined. If the input item is a value converted earlier during the same program execution, the pointer that results shall compare equal to that value; otherwise the behavior of the %p {or %jp} conversion is undefined. Note: It is assumed that pointer to function types may have different representations than other (data) pointer types; see 6.2.5p27. ------------------------------------------------------------------------