bug-gnulib
[Top][All Lists]
Advanced

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

Re: SIZEOF macro


From: Bruno Haible
Subject: Re: SIZEOF macro
Date: Fri, 25 Dec 2009 00:43:55 +0100
User-agent: KMail/1.9.9

Eric Blake wrote:
> macros.h defines SIZEOF, and test-argv-iter.c defines
> ARRAY_CARDINALITY, both of which are used to determine the size of an
> array.  I kind of prefer the name in test-argv-iter (to me, sizeof implies
> a size_t count of bytes, not the number of elements).  Is it okay to
> rename the macro in macros.h to ARRAY_CARDINALITY

No, please not. The name ARRAY_CARDINALITY is, while technically correct,
too technocratic and too long.
  - "Cardinality"? Ah, you mean the number of elements!
  - 17 characters long? That forces a line break in nearly every for()
    loop header in which it is used.

The macro SIZEOF is handy and is common knowledge. Search for it on Google [1]:
you find about 1000 definitions of it, in various packages. Whereas
ARRAY_CARDINALITY [2] occurs only in gnulib, coreutils, tar, and patch. In
other words, people looking at source code that uses SIZEOF will likely
recognize an old friend.

Bruno


[1] 
http://www.google.com/codesearch?as_q=define%5CsSIZEOF%5C%28&btnG=Code+suchen&hl=en&as_lang=c&as_license_restrict=i&as_license=&as_package=&as_filename=&as_case=y
[2] 
http://www.google.com/codesearch?hl=en&lr=&q=define%5CsARRAY_CARDINALITY%5C%28+lang%3Ac&sbtn=Suche




reply via email to

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