Skip to content

Commit

Permalink
docs/devel: make a statement about includes
Browse files Browse the repository at this point in the history
While not explicitly disallowing header macro abuse (because that
would make us hypocrites) lets at least address some things to think
about.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20230424092249.58552-17-alex.bennee@linaro.org>
  • Loading branch information
stsquad committed Apr 27, 2023
1 parent d035fb1 commit 6a0057a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/devel/style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,20 @@ putting those into qemu/typedefs.h instead of including the header.

Cyclic inclusion is forbidden.

Generative Includes
-------------------

QEMU makes fairly extensive use of the macro pre-processor to
instantiate multiple similar functions. While such abuse of the macro
processor isn't discouraged it can make debugging and code navigation
harder. You should consider carefully if the same effect can be
achieved by making it easy for the compiler to constant fold or using
python scripting to generate grep friendly code.

If you do use template header files they should be named with the
``.c.inc`` or ``.h.inc`` suffix to make it clear they are being
included for expansion.

C types
=======

Expand Down

0 comments on commit 6a0057a

Please sign in to comment.