When I read BlueZ source code, I often see char
arrays defined like this:
// bluez/android/sco-msg.h
static const char BLUEZ_SCO_SK_PATH[] = "\0bluez_sco_socket";
What good is it to define the first element as \\0
?
In your particular case this array is used as pathname for a PF_LOCAL
socket; see here . And leading NUL is used to point that address is an abstract one. From man 7 unix :
an abstract socket address is distinguished by the fact that sun_path[0] is a null byte ('\\0').
And this is the only reason why the first element is \\0
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.