char* vs void* (was: Comparison functions for qsort() and bsearch())

Tim McDaniel mcdaniel at adi.com
Sat Dec 29 06:37:47 AEST 1990


In the ANSI C standard, the concept of "representation" is not related
to semantics.  "Representation" refers to bit-level layout.

ANSI C standard, section 3.1.2.5, "Types" (page 25, lines 25-28 in
the ANSI edition):

   A pointer to void shall have the same representation and alignment
   requirements as a pointer to a character type.  Similarly, pointers
   to qualified or unqualified versions of compatable types shall have
   the same representation and alignment requirements.{16}  Pointers
   to other types need not have the same representation or alignment
   requirements.

Footnote {16} (page 24; the introduction says that "the footnotes ...
are not part of the standard"):

   16. The same representation and alignment requirements are meant
       to imply interchangeability as arguments to functions, return
       values from functions, and members of unions.

(page 24, lines 15-16):

   The three types char, signed char, and unsigned char are
   collectively called the _character_types_.

The "Types" section also requires identical representation and
alignment for certain other types.  "Compatable" is defined elsewhere
in the standard.

--
Tim McDaniel                 Applied Dynamics Int'l.; Ann Arbor, Michigan, USA
Work phone: +1 313 973 1300                        Home phone: +1 313 677 4386
Internet: mcdaniel at adi.com                UUCP: {uunet,sharkey}!amara!mcdaniel



More information about the Comp.lang.c mailing list