Is It necessary to use #include "CPU.h" in FreeRTOSCOnfig.h?

cancel
Showing results for 
Search instead for 
Did you mean: 

Is It necessary to use #include "CPU.h" in FreeRTOSCOnfig.h?

93 Views
toipaz
Contributor III

After creating a new project that does not provide Board from SDK, I am running the freeRTOS example, but there is a problem that it does not match.

So, I added CPU.h at the beginning of freertos\template\FreeRTOSConfig.h file.

In my case, because I use LPC54618, I add the following line at the top of "FreeRTOSConfig.h" file.

#include "LPC54618.h"

The SDK used is v2.9.0.

It works without problems, but something is weird. I don't think it's the right way to do it, but what is the correct way? I don't think it's the normal way...

Tags (3)
0 Kudos
1 Reply

87 Views
ErichS
Senior Contributor III

Hi @toipaz ,

it all depends what you are using later down below the FreeRTOSConfig.h.

The 'golden rule': include everything in a header file which is needed by that header file, not more and not less. So if you are using defines or types out of the CPU header file, you have to include it. Otherwise the header file is not 'self containing' and usage of it depends on include orders which is a programming error imho: including headers files shall be never depending on the order.

So this is probably what you see in your application that the header files are indeed not 'clean' but depend on the include order. And you 'fixed' it with that included CPU header file which is probably just a kind of 'hack' than a solution.

 

I hope this helps,

Erich

0 Kudos