bug-gnulib
[Top][All Lists]
Advanced

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

Re: [bug-gnulib] Re: base64


From: Bruno Haible
Subject: Re: [bug-gnulib] Re: base64
Date: Thu, 25 Nov 2004 16:39:01 +0100
User-agent: KMail/1.5

Stepan Kasal wrote:
> we have to parenthesize the parameter:
>
>      #define _BASE64_CEILING_DIV(n, k) ((n + (k-1)) / k)
>      #define BASE64_LENGTH(inlen) (_BASE64_CEILING_DIV((inlen), 3) * 4)

It's generally safer to parenthesize the use of the parameter inside
the macro, rather than in the macro invocation:

       #define _BASE64_CEILING_DIV(n, k) (((n) + ((k) - 1)) / (k))
       #define BASE64_LENGTH(inlen) (_BASE64_CEILING_DIV(inlen, 3) * 4)

Because with this style,
  1. as a programmer, you don't need to know whether something is implemented
     as a function or as a macro,
  2. when a function is changed into a function-like macro, you don't have to
     update all the callers.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]