Is char signed or unsigned by default?

前端 未结 7 797
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-21 06:49

In the book \"Complete Reference of C\" it is mentioned that char is by default unsigned.

But I am trying to verify this with GCC as well as Visual Stud

7条回答
  •  攒了一身酷
    2020-11-21 07:18

    As Alok points out, the standard leaves that up to the implementation.

    For gcc, the default is signed, but you can modify that with -funsigned-char. note: for gcc in Android NDK, the default is unsigned. You can also explicitly ask for signed characters with -fsigned-char.

    On MSVC, the default is signed but you can modify that with /J.

提交回复
热议问题