The example does not compile, it fails with:
error: passing argument 3 of ‘sd_journal_get_data’ from incompatible
pointer type
Cast to (const void **) to avoid this.
- r = sd_journal_get_data(j, "MESSAGE", &d, &l);
+ r = sd_journal_get_data(j, "MESSAGE", (const void **)&d, &l);
if (r < 0) {
fprintf(stderr, "Failed to read message field: %s\n", strerror(-r));
continue;
if (r < 0) {
fprintf(stderr, "Failed to read message field: %s\n", strerror(-r));
continue;