Skip to contentSkip to conversation

char is not signed char

DISCUSSION David L. Thompson 2 participants 2 messages Aug 11, 2000 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Has anybody else noticed that char is not signed char but unsigend char? If I write the following:

#include <stdio.h>

int main() {

	char a = -3;
	if(a > 0)
		printf("Ooops!\n");
	return 0;
}

and run it, I get Oooops!

Currently I have installed fsirl's 2.95.3 version of gcc.

Thanks,
David
--
.............................................................................

David L. Thompson                          The University of Montana
mailto:[email protected]                 Computer Science Department
http://www.cs.umt.edu/u/dthompsn           Missoula, MT  59812
                                           Work Phone : (406)257-8530

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#2 lore raw
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

"David L Thompson" writes:

David> Has anybody else noticed that char is not signed char but unsigend David> char? If I write the following:

Yes, this is up to the implementation to decide. For PowerPC,
unsigned char is more efficient and may even be defined by the ABI. You can invoke GCC with -fsigned-char if you require the other behavior.

David

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/