tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: KNF and the C preprocessor

On Mon, 10 Dec 2012, David Young wrote:

> What do people think about setting stricter guidelines for using the
> C preprocessor than the guidelines from the past?  Example guidelines:
> The C preprocessor MAY be used for

Firstly, I don't think we really need to specify what MAY be used, and
share/misc/style only contains one instance of must and no capitalised
directives at all. I would prefer that we kept to this informal style
guide rather than having a bunch of strict regulations.

> The C preprocessor MUST NOT be used for

"should not" :)

> 1 In-line code: 'static inline' subroutines are virtually always better
>   than macros.

There is already a paragraph about macros in the style guide, it could be
expanded in order to suggest that static inline functions are usually

> 2 Configuration management: use the compiler & linker to a greater
>   extent than the C preprocessor to configure your program for your
>   execution environment, your chosen compilation options, et cetera.

and something regarding this could be added. The main benefit as I see it
is that it better suits the modular kernel style we are slowly moving


Home | Main Index | Thread Index | Old Index