'Manual' include of FreeRTOS.h

laurensmiers wrote on Tuesday, April 03, 2018:


Sorry if this question was already asked somewhere else but I didn’t find any reference or other question about this.
This is just a question out of curiosity:
Why doesn’t f.e. task.h include FreeRTOS.h by itself (if we don’t include it before task.h, we get an error stating we should include it)? Why do we need to include it ourselves before including task.h?

There probably is a good reason why it is like this but I’d like to understand why.

Thanks in advance!


rtel wrote on Tuesday, April 03, 2018:

I replied to this via email, but for some reason it bounced.

It is done this was deliberately to make it clearer to people reading the code and debugging the code - the includes are explicit and not hidden. Some coding standards actually require that includes are not included from other includes to prevent complex interactions - and FreeRTOS attempts to do the same. There are a few instances where headers are included from other headers, but only where the order of inclusion is essential to make sure pre-processor definitions get defaulted correctly if they are absent from various configuration files.