views:

21

answers:

1

Easy question, that I can't seem to find a documentation-based answer for. In X-Code (v3.1) debugger if I hover over a struct variable such as sockaddr_in I see:

alt text

Notice the difference between sin_port and sin_family/sin_len. What is the meaning of '\002' in the case of sin_family. Why is it not displayed as just "2"?

+1  A: 

'\002' means 02 interpreted as an octal (base 8) number, similar to how '\x02' would be the same for a hex (base 16) number. As to why X-Code still uses octal, I'm stumped...

The reason it's only displaying octal representations for those variables is because they are declared as char's. This still doesn't explain the 'why octal' question, but it does answer the 'why' one.

Matthew Scharley
so sin_len is represented that way because it's of type _uint8_t?
SooDesuNe
Presumably. `__uint8_t` boils down to `unsigned byte` on most systems I think you'll find. It is due to it's type though, yes.
Matthew Scharley