JKop wrote:[color=blue]
> int a;
>
> short b;
>
> long c;
>
> char d;
>
>
> According to the Standard, are the above signed or unsigned?
>
>
> -JKop[/color]
int, short and long are, char is implementation defined.
If you need a signed or unsigned char, use:
signed char
or
unsigned char
Pete C. wrote:[color=blue]
> JKop wrote:[color=green]
>> int a;
>>
>> short b;
>>
>> long c;
>>
>> char d;
>>
>>
>> According to the Standard, are the above signed or unsigned?
>>
>>
>> -JKop[/color]
>
> int, short and long are, char is implementation defined.[/color]
I mean, int, short and long are signed.
- Pete
[color=blue]
> If you need a signed or unsigned char, use:
> signed char
> or
> unsigned char
>
> - Pete[/color]
JKop wrote:
[color=blue]
> int a;
>
> short b;
>
> long c;
>
> char d;
>
>
> According to the Standard, are the above signed or unsigned?
> ...[/color]
Plain 'int', 'short' and 'long' are always equivalent to 'signed int',
'signed short' and 'signed long', unless used to declare a bit-field (in
which case it is implementation-defined whether they are signed or
unsigned).
A plain 'char' is always a separate type, different (as a type) from
both 'signed char' and 'unsigned char'. However, the value range of char
always coincides with value range of either 'signed char' or 'unsigned
char' (which one - implementation defined). Also, the same comment about
bit-fields applies to plain 'char' as well.
JKop wrote:
[color=blue]
> Conforming to the Standard, should the following compile?:
>
>
> void Garda(signed short int);
>
> int main(void)
> {
> short p = 4;
>
> Garda(p);
> }
>
>
> void Garda(short frog)
> {
> frog = 5;
> }[/color]
Yes, it should. Both declarations of 'Garda' "[...] agree exactly both
in the type of the value returned and in the number and type of
parameters [...]" (8.3.5/3). Additionally, note in 13.1/3 says that
"[...] function declarations that have equivalent parameter declarations
declare the same function [...]".
Comment