CL /J

Syntax

The option is /J only.

Relations

The /J option weakly implies -D_CHAR_UNSIGNED.

This option passes to the front-end C and C++ compilers (C1 and C1XX) only.

Behaviour

For most integral types, the signed type and the unmodified type are one and the same, and differ from the unsigned type. The char type is different, such that signed char, char and unsigned char are three distinct types. The question then arises of whether the unmodified char is signed or unsigned when promoted to a larger integral type. Ordinarily, it is signed. The /J option specifies that such promotions be unsigned.

Example

The following fragment overloads a function so that its one argument may be each of the three single-byte character types.

int func (signed char ch)
{
    return ch;                  // sign-extended
}

int func (char ch)
{
    return ch;                  // sign-extended ordinarily, zero-extended if /J
}

int func (unsigned char ch)
{
    return ch;                  // zero-extended
}

All that each version does is to promote its one argument to an integer. The fragment compiles with or without /J. The difference lies entirely in whether the unmodified char is sign-extended or zero-extended.