What causes a char to be signed or unsigned when using gcc? : <p>What causes if a <code>char</code> in C (using gcc) is signed or unsigned? I know that the standard doesn't dictate one over the other and that I can check <code>CHAR_MIN</code> and <code>CHAR_MAX</code> from limits.h but I want to know what triggers one over the other when using gcc</p>

<p>If I read limits.h from libgcc-6 I see that there is a macro <code>__CHAR_UNSIGNED__</code> which defines a "default" char signed or unsigned but I'm unsure if this is set by the compiler at (his) built time.</p>

<p>I tried to list GCCs predefined makros with</p>

<pre><code>$ gcc -dM -E -x c /dev/null | grep -i CHAR
#define __UINT_LEAST8_TYPE__ unsigned char
#define __CHAR_BIT__ 8
#define __WCHAR_MAX__ 0x7fffffff
#define __GCC_ATOMIC_CHAR_LOCK_FREE 2
#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
#define __SCHAR_MAX__ 0x7f
#define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1)
#define __UINT8_TYPE__ unsigned char
#define __INT8_TYPE__ signed char
#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
#define __CHAR16_TYPE__ short unsigned int
#define __INT_LEAST8_TYPE__ signed char
#define __WCHAR_TYPE__ int
#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
#define __SIZEOF_WCHAR_T__ 4
#define __INT_FAST8_TYPE__ signed char
#define __CHAR32_TYPE__ unsigned int
#define __UINT_FAST8_TYPE__ unsigned char
</code></pre>

<p>but wasn't able to find <code>__CHAR_UNSIGNED__</code></p>

<p>Background: I've some code which I compile on two different machines:</p>

<p><strong>Desktop PC:</strong></p>

<ul>
<li>Debian GNU/Linux 9.1 (stretch)</li>
<li>gcc version 6.3.0 20170516 (Debian 6.3.0-18)</li>
<li>Intel(R) Core(TM) i3-4150</li>
<li>libgcc-6-dev: 6.3.0-18</li>
<li><code>char</code> is signed</li>
</ul>

<p><strong>Raspberry Pi3</strong>:</p>

<ul>
<li>Raspbian GNU/Linux 9.1 (stretch)</li>
<li>gcc version 6.3.0 20170516 (Raspbian 6.3.0-18+rpi1)</li>
<li>ARMv7 Processor rev 4 (v7l)</li>
<li>libgcc-6-dev: 6.3.0-18+rpi</li>
<li><code>char</code> is unsigned</li>
</ul>

<p>So the only obvious difference is the CPU architecture...</p>
