DOCERR: Online Help Solution for C4139 Warning Is IncorrectLast reviewed: July 17, 1997Article ID: Q64640 |
6.00 6.00a 6.00ax 7.00 | 6.00 6.00a | 1.00
MS-DOS | OS/2 | WINDOWSkbtool kbdocerr The information in this article applies to:
SYMPTOMSUsing hexadecimal constants in strings results in the following compiler warning
C4139: '0xsequence' : hex escape sequence is out of rangeif the hexadecimal digits following the "\x" escape character evaluate to a number too large to be converted to an ASCII character. The online help systems for Microsoft C versions 6.0, 6.0a, and 6.0ax, and QuickC versions 2.5 and 2.51, show an example of code that produces the following warning:
printf("\x7bell\n"); /* Error-causing code */Next, the following workaround is given to resolve the problem:
printf("\x007bell\n"); /* Supposed to resolve problem */Unfortunately, the second printf statement produces the same error as the first. With C versions 6.0 and later, the first printf generates the error:
C2022: '1982' : too big for characterThe online help for C version 8.0 for MS-DOS provides a correct workaround. However, it incorrectly references the octal digits in the workaround as hexadecimal digits. The online help for Visual C++ 1.5 and Visual C++ 1.0 provide the correct information.
CAUSEThe compiler treats every potential hexadecimal digit following the "\x" as part of the constant. This means that "\x007bell" is interpreted as a 5-digit hexadecimal value followed by "ll". Because "\x007be" equals 1982 decimal, a C2022 error will be generated because this value is too large for an ASCII character.
RESOLUTIONThree valid workarounds are listed below:
REFERENCESAdditional information is given in the C 6.0 README.DOC file in Part 2: "Differences between C 5.1 and 6.0," under the subtitle "Hexadecimal Constants in Strings."
|
Additional reference words: 1.00 6.00 6.00a 6.00ax 7.00 8.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |