0

I was browsing the Systemd / Journald header files, and in /usr/include/systemd/sd-journal.h, I noticed this line of code:

typedef struct sd_journal sd_journal;

It seems that the struct sd_journal is defined as... sd_journal. What does this reflexive / recursive typedef actually mean?

Jonathan Wilbur
  • 1,057
  • 10
  • 19
  • This is a C-ism. Looking for a duplicate – NathanOliver Dec 19 '22 at 21:34
  • `sd_journal` is defined as `struct sd_journal`. Makes a big difference in C. – BoP Dec 19 '22 at 22:56
  • In C the `sd_journal` in `struct sd_journal`, being the struct tag, is in the tag namespace; that’s separate from the global namespace, and the typedef creates a new name in the global namespace. In C++ this isn’t necessary. – Pete Becker Dec 20 '22 at 01:03

0 Answers0