On 1/15/2011 7:35 PM, James Waldby wrote:
> On Sat, 15 Jan 2011 15:08:17 -0500, Eric Sosman wrote:
>> On 1/15/2011 12:58 PM, hqin wrote:
>>> Here is the compiling error:
>>> ace:src hqin$ make
>>> gcc -O3 -Wall -c -o misc.o misc.c
>>> In file included from misc.c:21:
>>> misc.h:106: error: conflicting types for ‘psort’
>>> /usr/include/stdlib.h:310: error: previous declaration of ‘psort’ was
>>> here
>>> [...]
>> A Standard-conforming<stdlib.h> must not even mention `psort',
>> much less declare it. [...]
>
> Can you provide a reference that indicates `psort' is a GNU or gcc
> extension? I've seen web pages that refer to BSD and Mac but not GNU.
It's not really a matter of which extension or addition or
decoration `psort' belongs to: The point is that the C Standard
does not list `psort' as one of the identifiers <stdlib.h> is
allowed to declare. It is an identifier in the programmer's "name
space," an identifier the programmer must be able to use freely
without fear that <stdlib.h> or <ctype.h> or <whatever.h> or the
compiler itself will somehow use in a conflicting way. As a
programmer, you can use `x' in any way you choose; same with `psort'.
>> Unfortunately, I sort of suspect this won't solve the problem
>> altogether. In light of the report elsethread that `dprintf' is also
>> doubly declared, [...]
>
> For `dprintf' it's clear that both GNU and Apple are guilty of
> extension. According to "info dprintf" on linux,
>
> "These functions are GNU extensions, not in C or POSIX.
> Clearly, the names were badly chosen. Many systems (like
> MacOS) have incompatible functions called dprintf(),
> usually some debugging version of printf() ..."
It's a continuing problem. The C Standard recognizes only two
classes of code-writers: "implementors" and "users." The Standard
carefully divides the identifier name space into three parts, like
Caesar's Gaul: (1) identifiers that the implementors must provide
and that the users can rely upon, (2) identifiers the implementors
can use for whatever purposes they please, and (3) identifiers that
the users can employ for whatever purposes *they* please. This gives
a measure of sanity: The users can be sure that the implementors will
not misappropriate `farthingale', and the implementors can be sure
that the users will not try to use `EFFORT'. (Yes, the division is
sometimes very peculiar; put it down to "hysterical raisins.")
*But* the Standard offers no way for different groups of "users"
to identify themselves and to avoid trampling on each other's names.
If you want to use a popular extension like POSIX, you must give up
on trying to use `fork' as an identifier of your own. If you want to
use the Fastest Fourier Transform in the West, you must avoid trying
to use `fftw_complex' for your own purposes. Eventually, you will
surely find that extension A and library B both define `dingbat', and
do so incompatibly. The "badly chosen" names mentioned in the man
page are really not the fault of the choosers; it is inevitable that
conflicts of this kind will arise. And C per se offers no solution.
C'est la vie.
--
Eric Sosman
lid