mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/event: change example in doc to be type safe
C is not a particularly safe language, but let's at least encourage best practices so that the few safety features C have are effectively used.
This commit is contained in:
parent
a2259db3bd
commit
00db1dfc81
@ -75,13 +75,13 @@
|
||||
*
|
||||
* static void custom_handler(event_t *event)
|
||||
* {
|
||||
* custom_event_t *custom_event = (custom_event_t *)event;
|
||||
* custom_event_t *custom_event = container_of(event, custom_event_t, super);
|
||||
* printf("triggered custom event with text: \"%s\"\n", custom_event->text);
|
||||
* }
|
||||
*
|
||||
* static custom_event_t custom_event = { .super.handler = custom_handler, .text = "CUSTOM EVENT" };
|
||||
*
|
||||
* [...] event_post(&queue, (event_t *)&custom_event)
|
||||
* [...] event_post(&queue, &custom_event.super)
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*
|
||||
* @{
|
||||
|
Loading…
Reference in New Issue
Block a user