I notice that hal_sensors.h does not include anything that provides _base_object_methods . Therefore, hal.h must be included before anything that inherits from hal_sensors.h . What is the reasoning behind this, or is this an oversight?
I normally organize my includes starting with "most local" first and "most global" see the accepted answer here for reasoning: https://stackoverflow.com/questions/276 ... -practices . Does Chibi have different guidance on this issue?
Include order: why must hal.h be included before hal_accelerometer.h, etc.?
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Include order: why must hal.h be included before hal_accelerometer.h, etc.?
Hi,
There are tens of headers in HAL, all the common header are included in hal.h, the remaining ones depends on things imported by hal.h so are included afterward.
The pattern is, first hal.h then other HAL-related headers.
For simplicity we never hand-pick headers already included by hal.h, we just import the whole thing, the advantage is that if hal.h changes its internal organization then there are no dependencies to fix in other places.
halobject.h is one of those fundamental headers included by hal.h so it is not included separately.
Giovanni
There are tens of headers in HAL, all the common header are included in hal.h, the remaining ones depends on things imported by hal.h so are included afterward.
The pattern is, first hal.h then other HAL-related headers.
For simplicity we never hand-pick headers already included by hal.h, we just import the whole thing, the advantage is that if hal.h changes its internal organization then there are no dependencies to fix in other places.
halobject.h is one of those fundamental headers included by hal.h so it is not included separately.
Giovanni
Who is online
Users browsing this forum: No registered users and 23 guests