Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It is permitted to have a lot of macros. Why does that trouble you?</p> <p>A macro like </p> <pre><code> #define STRUCT_KFIFO_PTR(type) \ struct __STRUCT_KFIFO_PTR(type, 0, type) </code></pre> <p>is not a function-like macro.</p> <p>A macro like </p> <pre><code> #define kfifo_initialized(fifo) ((fifo)-&gt;kfifo.mask) </code></pre> <p>could be also used on the left side of some assignment (even if you probably should not do that). And it is shorter to write than the corresponding <code>inline</code> function</p> <pre><code> static inline unsigned kfifo_initialezed_f(struct __kfifo *fifo) { return fifo-&gt;kfifo.mask; } </code></pre> <p>and more importantly the macro <code>kfifo_initialized</code> would work with several different declarations of its <code>fifo</code> actual argument (it is "generic" in some limited sense).</p> <p>A macro like</p> <pre><code> #define __STRUCT_KFIFO(type, size, recsize, ptrtype) \ { \ __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \ type buf[((size &lt; 2) || (size &amp; (size - 1))) ? -1 : size]; \ } </code></pre> <p>would expand to a declaration equivalent to an array <code>buf[-1]</code> if given a <code>size</code> of <code>3</code> and that would make the compiler yell. (The recent C++2011 standard also has <code>static_assert</code> for such purposes).</p> <p>So I don't understand why you are surprised. The <em>C</em> preprocessor is useful (IMHO it is even not powerful enough). Why avoid using it?</p> <p>This is <strong>free software</strong>; if you don't like that source file, you could <strong>work to improve it</strong> (and that would take time) to propose a better solution. I do like the current one.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload