Page 1 of 1

Include order (chprintf.h)

Posted: Mon Jun 05, 2023 9:32 pm
by elagil

I use clang-format for automatically sorting include files by scope and name, and this leads to compilation problems with some headers.

One such example is

Code: Select all

#include "chprintf.h"
#include "hal.h"

Since chprintf.h depends on type declarations from hal.h, this does not compile. Would you consider adding the hal.h include into the chprintf.h header? Otherwise, I see no way of fixing this issues (except for not using my formatter and sorting by hand).

Thank you in advance

Re: Include order (chprintf.h)

Posted: Tue Jun 06, 2023 5:34 am
by Giovanni

Moving in bug reports. In which file is that problem?


Re: Include order (chprintf.h)

Posted: Tue Jun 06, 2023 3:00 pm
by elagil
It is in ChibiOS/os/hal/lib/streams/chprintf.h. Here is the diff that fixes it for me:

Code: Select all

diff --git a/os/hal/lib/streams/chprintf.h b/os/hal/lib/streams/chprintf.h
index e1e19b1c8..e45f157d0 100644
--- a/os/hal/lib/streams/chprintf.h
+++ b/os/hal/lib/streams/chprintf.h
@@ -27,6 +27,8 @@
 #include <stdarg.h>
+#include "hal.h"
  * @brief   Float type support.

I only have to add the hal.h include to it.