How to avoid circular dependencies in libraries?

There’re multiplatform libraries that extract their platform-dependent code into portable files. Example: FreeRTOS with its ports, or CANopenNode with its drivers. Basically, the main abstract library provides headers with declarations of methods that the platform-dependent library needs to define.

I’d like to make libraries that play by platformio rules. I.e. I create a driver/port and put it into a separate library. That driver port has to include headers from the parent library, and the parent library usually includes the driver library directly. This creates a circular dependency. It actually works and compiles properly, but platformio complains about the circular dependency and that makes me uneasy.

For my own code, I went down the route of using an intermediate library and weak symbols. That works well. But for other people’s code, i don’t have the luxury of restructuring their code.

What’s the proper way of dealing with this situation? Is there a way to “bless” certain dependency so platform ignores its circularity? Any other ways?

I have the same problem. Any suggestion on this?

+1. I’m also facing the same problem.