For Apple Implementations (Cocoa / CocoaTouch), is uint8_t always the same type as unsigned char?

While walking through the sample code application for the iPhone, I found a couple of send and receive methods that actually had the same signature definitions, except for the value types associated with one of the variables.

Inside the header:

- (void)receivedData: (unsigned char *)data length:(NSUInteger)len;
- (void)sendData:     (uint8_t*)       data length:(NSUInteger) len;

These methods are used as wrappers for the send / receive process, which effectively passes a pointer to an array of bytedata written to and from data streams. I found these method signatures a little curious, and since I'm new to Cocoa / Cocoa Touch dev, I decided to check the type definition uint8_t. I found that it uint8_tis defined as unsigned charinternally stdint.h, and so the variables datafor these methods are exactly the same. At least this applies to stdint.hwhich is connected in Xcode 4.2.

However, after doing some further research regarding type uint8_t, I found this question regarding usage uint8_tvs. unsigned char. The consensus seems to be that often these two types of values ​​are exactly the same, but with some implementations of the standard C libraries they can be different. Ergo, you should not believe that they will be the same data type when creating portable code.

With that said, can it be assumed that, within the framework of the Apple / Objective-C programming environment, the value uint8_twill be the same as unsigned char, or should I follow the same advice mentioned in the above question?

, , , , -, , Apple ( ), .

+5
4

( ), , char - , Mac OS X , iOS. , , unsigned char uint8_t .

, , , , , , , "" "uint8_t" - , , .

+4

, uint8_t typedef unsigned char Mac OS X.

, POSIX ( Mac OS X), POSIX , char 8-.

(2.12.2 char) " char , . XBD ( )."

(3.84 ) " , , , . " ". 8 ".

+4

C99 uint8_t unsigned char, Mainstream, UNIX- , Apple OS, , , (pre- post-C99), , unsigned char 8 .

uint8_t, , , . , unsigned char.

+3

I would say that you can use these tools in an Apple environment. As far as I understand, strange implementations that are considered unsigned charas something other than 8 bytes are small, far apart and, in my humble opinion, an idiot;)

Apple, which bases its OS on UNIX-like databases, will almost certainly never change the implementation unsigned char.

+2
source

All Articles