C language > Expert questions

CHAR

(1/2) > >>

John Z:
In both 32 bit and 64 bit compiling some mini zip code I ran across this warning message:
C:\Program Files\PellesC\Files\.....\Zip\miniz.h(4117): warning #2074: Escape sequence '\xae' is out of range for 'char'.
C:\Program Files\PellesC\Files\.....\Zip\miniz.h(4117): warning #2074: Escape sequence '\x82' is out of range for 'char'.

But 'char' storage is one byte which should go to \xff so it seems it is checking for char < 127

Is it a valid warning?

John Z

MrBcx:
Possible cause:

CHAR is signed char
BYTE is unsigned char

https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types

John Z:
Thanks MrBCX,

Makes sense if CHAR is signed.  Looks like signed CHAR is somewhat implementation specific.
Std on x86(mostly), unsigned on ARM generally and changeable with an option.
After your hint I found:
--- Quote ---"Is char type is signed by default in C?
By default, char behaves like an unsigned char . To change this default, you can use the DFTCHAR(*SIGNED|*UNSIGNED) option or the #pragma chars directive. See DFTCHAR(*SIGNED|*UNSIGNED) in the ILE C/C++ Compiler Reference for more information.

Character types - IBM
ibm.com
--- End quote ---

Thanks - with this looks like not a mistake warning.

John Z

MrBcx:
Robert Wishlaw shared this tip/trick a couple years ago:

Here is a one liner to check the compiler's default signedness for the char data type.

printf("%d\n",'\x80');


-128 means default is signed char

128 means default is unsigned char

Default for Nuwen, MSVC, CLang and Pelles C is signed.

To change MSVC and Pelles C to unsigned char default add

/J

flag to command line.

To change Nuwen and CLang to unsigned char default add

-funsigned-char

flag to command line.

Robert:

--- Quote from: MrBcx on November 05, 2023, 12:58:50 AM ---Robert Wishlaw shared this tip/trick a couple years ago:

Here is a one liner to check the compiler's default signedness for the char data type.

printf("%d\n",'\x80');


-128 means default is signed char

128 means default is unsigned char

Default for Nuwen, MSVC, CLang and Pelles C is signed.

To change MSVC and Pelles C to unsigned char default add

/J

flag to command line.

To change Nuwen and CLang to unsigned char default add

-funsigned-char

flag to command line.

--- End quote ---

As well as the above, additional information is in the Remarks section of the BCX Documentation for char at

https://bcxbasiccoders.com/webhelp/html/variables.htm#char

Navigation

[0] Message Index

[#] Next page

Go to full version