Include order (chprintf.h) Topic is solved

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

Include order (chprintf.h)

Post by elagil »

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: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Include order (chprintf.h)

Post by Giovanni »

Hi,

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

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

Re: Include order (chprintf.h)

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Include order (chprintf.h)

Post by Giovanni »

Hi,

Fixed in trunk.

Giovanni
Post Reply