Signed?

J

JKop

int a;

short b;

long c;

char d;


According to the Standard, are the above signed or unsigned?


-JKop
 
P

Pete C.

JKop said:
int a;

short b;

long c;

char d;


According to the Standard, are the above signed or unsigned?


-JKop

int, short and long are, char is implementation defined.
If you need a signed or unsigned char, use:
signed char
or
unsigned char

- Pete
 
A

Andrey Tarasevich

JKop said:
int a;

short b;

long c;

char d;


According to the Standard, are the above signed or unsigned?
...

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.
 
J

JKop

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;
}
 
A

Andrey Tarasevich

JKop said:
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;
}

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 [...]".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,170
Messages
2,570,925
Members
47,468
Latest member
Fannie44U3

Latest Threads

Top