Include order (chprintf.h) Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
elagil
Posts: 92
Joined: Tue Sep 19, 2017 7:38 am
Has thanked: 8 times
Been thanked: 7 times

Include order (chprintf.h)  Topic is solved

Postby elagil » Mon Jun 05, 2023 9:32 pm

Hello!

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

User avatar
Giovanni
Site Admin
Posts: 14462
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1078 times
Been thanked: 922 times
Contact:

Re: Include order (chprintf.h)

Postby Giovanni » Tue Jun 06, 2023 5:34 am

Hi,

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

Giovanni

elagil
Posts: 92
Joined: Tue Sep 19, 2017 7:38 am
Has thanked: 8 times
Been thanked: 7 times

Re: Include order (chprintf.h)

Postby elagil » Tue Jun 06, 2023 3:00 pm

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.

User avatar
Giovanni
Site Admin
Posts: 14462
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1078 times
Been thanked: 922 times
Contact:

Re: Include order (chprintf.h)

Postby Giovanni » Sun Dec 17, 2023 12:02 pm

Hi,

Fixed in trunk.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 6 guests