[
https://issues.apache.org/jira/browse/DISPATCH-836?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17313951#comment-17313951
]
Jiri Daněk commented on DISPATCH-836:
-------------------------------------
[~chug] What do you think about this? The example does not have a header file
for this .c file, but if it was there, it would be directly below #include
Python in the After section.
h3. Before
{noformat}
#include <Python.h>
#include <qpid/dispatch/alloc.h>
#include <qpid/dispatch/ctools.h>
#include <qpid/dispatch/log.h>
#include <memory.h>
#include <inttypes.h>
#include <stdio.h>
#include "entity.h"
#include "entity_cache.h"
#include "config.h"
#ifdef QD_MEMORY_DEBUG
#include <execinfo.h>
#include "log_private.h"
#endif
{noformat}
h3. After
{noformat}
#include <Python.h>
#include <inttypes.h>
#include <memory.h>
#include <stdio.h>
#include <qpid/dispatch/alloc.h>
#include <qpid/dispatch/ctools.h>
#include <qpid/dispatch/log.h>
#include "config.h"
#include "entity.h"
#include "entity_cache.h"
#ifdef QD_MEMORY_DEBUG
#include <execinfo.h>
#include "log_private.h"
#endif
{noformat}
It is produced by the following config
{noformat}
BasedOnStyle: Google
[...]
IncludeCategories:
- Regex: '^<Python.h>$'
Priority: -1
- Regex: '^<qpid/.*\.h>'
Priority: 3
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 4
{noformat}
> Source file organization suffers from include hell
> --------------------------------------------------
>
> Key: DISPATCH-836
> URL: https://issues.apache.org/jira/browse/DISPATCH-836
> Project: Qpid Dispatch
> Issue Type: Improvement
> Components: Container, Router Node, Routing Engine
> Affects Versions: 0.8.0
> Reporter: Charles E. Rolke
> Priority: Minor
> Fix For: Backlog
>
>
> Adding an innocent looking #include to some module may unleash a barrage of
> errors instead of simply defining the header's interface. Reordering and/or
> adding more #include statements is required to get it right.
> A good way to address this is to make certain that each module.h file
> compiles cleanly on its own. It is tedious and pretty unrewarding to check
> each file. One strategy to address this problem is for each module to
> _#include module.h_ as the first include\[1\]. Then every compile checks that
> the module.h files compiles cleanly. This strategy is recommended by
> astitcher and used by qpid-cpp with great results.
> \[1\] One exception to this rule is including the #include Python.h ahead of
> all others. This is a requirement.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]