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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

1,662 次查看
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...

标记 (3)
0 项奖励
回复
1 回复

1,656 次查看
ErichStyger
Specialist I

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 项奖励
回复