このコードが実際に意味するものを理解したいと思います。関数が中括弧に入れられる最後の部分。 broadcast_open関数は何とか関数broadcast_recvを呼び出していますか?はいの場合、どうですか?Cのコールバックのケースを理解する
struct broadcast_callbacks
{
void (*callback)(struct broadcast_conn *, const rimeaddr_t *from);
};
次にライン
static const struct broadcast_callbacks broadcast_call = {broadcast_recv};
そのメンバーbroadcast_recv
機能へのポイント新しいStructオブジェクトが作成されます。
static void broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *from)
{
printf("broadcast message received from %d.%d: '%s'\n",
from->u8[0], from->u8[1], (char *)packetbuf_dataptr());
}
static const struct broadcast_callbacks broadcast_call = {broadcast_recv};
static struct broadcast_conn broadcast;
PROCESS_THREAD(example_broadcast_process, ev, data)
{
broadcast_open(&broadcast, 129, &broadcast_call);
...
}
void broadcast_open(struct broadcast_conn *c, uint16_t channel, const struct broadcast_callbacks *u)
{
abc_open(&c->c, channel, &broadcast);
c->u = u;
channel_set_attributes(channel, attributes);
}
こんにちは、返信ありがとうございます。ここでbroadcast_open – Acid
空隙 broadcast_open(構造体broadcast_connの*のC、uint16_tチャネル、 \t CONST構造体broadcast_callbacks * U)を {abc_open(&C-> C、チャネル、およびブロードキャスト)のためのコードです。 c-> u = u; channel_set_attributes(channel、attributes); } – Acid
私が特に知りたいのは、中括弧の構文です...なぜ、どのように使用されたのですか? – Acid