This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: int8_t problem


>> What should I do?
>
> Don't use lint which doesn't understand GCC __attribute__ extensions?

That should fix his __attribute__ issue, but I still see a minor
problem with libc/posix/sys/types.h.  When a non-GCC compiler is used,
it typedefs int8_t to plain 'char', which is incorrect if char is
unsigned.

I just checked, and OpenBSD 4.0 <sys/types.h> and <stdint.h> both
typedef int8_t to 'signed char' unconditionally.  Solaris 10
<sys/types.h> and <stdint.h> both typedef int8_t to plain 'char' if
char is signed, else to 'signed char' if C89 or later, else they leave
int8_t undefined.  Both approaches work; the former is simpler.  So
how about this patch?

2006-11-16  Paul Eggert  <eggert@cs.ucla.edu>

	* posix/sys/types.h (int8_t) [!__GNUC_PREREQ (2, 7)]:
	Typedef to signed char, not to plain char, so that code
	using int8_t operates correctly when char is unsigned.
	Problem reported by Okko Willeboordse.

--- posix/sys/types.h	28 Feb 2006 19:11:24 -0000	1.46
+++ posix/sys/types.h	16 Nov 2006 23:19:57 -0000
@@ -160,7 +160,7 @@ typedef unsigned int uint;
 /* These types are defined by the ISO C99 header <inttypes.h>. */
 # ifndef __int8_t_defined
 #  define __int8_t_defined
-typedef	char int8_t;
+typedef	signed char int8_t;
 typedef	short int int16_t;
 typedef	int int32_t;
 #  if __WORDSIZE == 64


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]