라벨이 char인 게시물 표시

OS/2 codes: How to make 'char' type of gcc + kLIBC compatible with IBM Visual Age C/C++ and Open Watcom C/C++

When you compile sources for IBM Visual Age C/C++(later VAC) or Open Watcom C/C++(later OW) with gcc/g++ + kLIBC(later gcc), there is a thing you should notice. It is char type. char type is a primitivie type to hold a character on C/C++. And it is usually 1-byte size. If it holds an integer, it can be singned char or unsigned char according to implementaiton. VAC and OW define char to unsigned char by default. Its range is 0 to 255. On the other hands, gcc define char to signed char by default. Its range is -128 to 127. This difference has no problem usually. However, if bit-wise operation is used or DBCS characters manipulations are performed, potential problems may occur. For example, if you did right-bit-shift by 1 on a char varaible holding 128(10000000 in binary), you would expect 64(01000000b). But you may get 64(01000000, VAC and OW) or -64(11000000b, gcc). This is because right-bit-shift conserve MSB(sign-bit) if signed-type. Try to build and run the follo...