casting int constants to pointers (was: switch (expression))

Karl Heuer karl at haddock.ISC.COM
Fri Jul 15 04:25:06 AEST 1988


In article <59881 at sun.uucp> guy at gorodish.Sun.COM (Guy Harris) writes:
>[sbrk(), as well as shmop(), returns (char *)-1 on error]

Neither sbrk() nor shmop() is part of the ANSI C library.  I hope POSIX will
fix this.

>Unfortunately, we're stuck with the sins of the past, such as system calls
>returning -1 even when they're returning pointers and special signal handler
>values such as "(int (*)())1" (changed to "(void (*)...", which still doesn't
>fix the problem in question),

In ANSI C, the values of SIG_DFL, SIG_IGN, and SIG_ERR are not specified.
Providing them as macros does fix the problem in question.

It would seem that the correct fix for sbrk() and shmop() is to similarly
provide SBRK_ERR and SHMOP_ERR.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.std.c mailing list