Search the forum, there are some discussion on the topic (and a very recent one in the Code Completion sub forum).
Well, after reading the topic and code examples I gradually come to a conclusion that I should make some workaround or partial solution, but not the complete one needed for CC. Since the purpose is just to tell 'make' what files it should check for changes before turning a unit into an object file, the procedure of extracting dependencies could be simplified.
I suppose the following algorithm will do the job:
For every unit in a build target:
- 1) recursively scan for #include directives ignoring #ifdef-s and resolve paths of included files by searching these files in include path.
- 2) remove duplicate includes.
- 3) add all successfully found includes to dependencies of current unit's target.
- 4) forget includes that cannot be found or add them somewhere close to target as remarks.
This way missing dependencies won't trigger 'make' to complain about themselves, but all of existing dependencies will cause a rebuild of certain targets if necessary. There may be a small overhead caused by including false, but existing, dependencies, but this won't break anything.