c - Why weren't new (bit width specific) printf() format option strings adoped as part of C99? -
How to format string in cross-platform printf ()
C (research, the number of bits Keeping in mind, I hope every integer argument should be printf ()
) The article I ran across discusses non-standard options that are printf ()
Format string, such as (which seems to be a Microsoft-specific extension) can be passed:
printf ("% I32d \ n", my32bitInt );
It states that:
The ISO 99 99 contains inttypes.h header file that contains several macros for use in platform-independent printfaces. Coding
... and then lists a set of macros that can be said in the header. By looking at the header file, I must write to use them:
printf ("%" PRId32 "\ n", my32bitInt);
My question is: Am I forgetting something? Is this really the standard C99 method? If so, why? (Although I am not surprised that I have never seen a code which uses the format string in this way, because it looks very cumbersome ...)
The argument is that & lt; Inttypes.h & gt; The current practice is standardization:
& lt; Inttypes.h & gt; was taken from the header of the same name found on several existing 64-bit systems.
But the rest of the text does not write about those macros, and I do not miss that they were doing the exercises on time.
What are the speculation now, but the experience of how the standardization committees work.
An advantage of the C99 macros on the additional format specification standardization for printf (note that C99 also added something) is that & lt; Inttypes.h & gt;
and and lt; Stdint.h & gt;
When you are already supporting the necessary attributes in an implementation, there is enough typing and writing two files with macros. This reduces the cost of making existing implementation conferences, reduces the risk of breaking existing programs, which uses the use of existing implementation features (does not interfere with standard means) and to close the programs consistent with the implementation Provides those who do not have this header (they can be provided by the program) Additionally, if Yanwyn specific methods were already different, so it is not suitable to apply a second.
Comments
Post a Comment