The "hh" specifier was introduced in C99, and I am using this specifier in my code. (Code example to follow...) My compiler is GCC 3.3.2, my OS is Solaris 8, and my C library is SUNW libc v1.21. The "hh" specifier has no effect when this code runs. When I switch over to Solaris 10, GCC 3.4.6 and SUNW libc 1.23, the code functions as expected. I compiled with and without the "-std=c99" option, and it made no difference. My conclusion is that the SUNW libc 1.21 does not support this C99 feature. I guess my question is (1) why not? and (2) is there some way to find out whether a particular C library supports a particular C99 feature? Thank you!
The code is simple:
uint8_t* scanByte;
uint32_t uScratch;
uint8_t aByte;
strcpy(scanByte,"0xF9");
sscanf(scanByte,"%x", &uScratch );
sscanf(scanByte,"%hhx", &aByte );
printf("scanByte: %s uScratch: %x aByte: %x\n", scanByte, uScratch, aByte);
Solaris 8 output:
scanByte: 0xF9 uScratch: f9 aByte: 0
Solaris 10 output:
scanByte: 0xF9 uScratch: f9 aByte: f9
UPDATE:
I have changed the code as follows, and re-run:
unsigned int uScratch;
unsigned char aByte;
int scanResult1;
int scanResult2;
unsigned char* scanByte;
scanByte=malloc(5);
strcpy(scanByte,"0xF9");
scanResult1 = sscanf(scanByte,"%x", &uScratch );
printf("scanByte: %s uScratch: %x scanResult1: %d\n", scanByte, uScratch, scanResult1);
scanResult2 = sscanf(scanByte,"%hhx", &aByte );
printf("scanByte: %s uScratch: %x scanResult2: %d\n", scanByte, uScratch, scanResult2);
Solaris 10 output:
scanByte: 0xF9 uScratch: f9 scanResult1: 1
scanByte: 0xF9 uScratch: f9 scanResult2: 1
Solaris 8 output:
scanByte: 0xF9 uScratch: f9 scanResult1: 1
scanByte: 0xF9 uScratch: f9 scanResult2: 0
So, yup, something about Solaris 8 + scanf + hhx, as I originally suspected. But my question stands: how does one determine whether a particular C99 feature is supported by libc? GCC 3.3.2 is a C99 compiler, but obviously the libc version doesn't fully support C99. How do I find out what C99 features are not supported?