Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!oliveb!sun!gorodish!guy From: guy@gorodish.Sun.COM (Guy Harris) Newsgroups: comp.std.c Subject: Re: casting int constants to pointers (was: switch (expression)) Message-ID: <60416@sun.uucp> Date: 19 Jul 88 08:27:29 GMT References: <1988Jul12.105547.13268@light.uucp> <755@vsi.UUCP> <59881@sun.uucp> <5153@haddock.ISC.COM> Sender: news@sun.uucp Lines: 28 > >[sbrk(), as well as shmop(), returns (char *)-1 on error] > > Neither sbrk() nor shmop() is part of the ANSI C library. Yes, I think we all knew that, but those were the examples the previous poster used.... > >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. Which problem is that? Given any program using those macros, you can write an equivalent program that doesn't use them by subsituting the definition of those macros for each occurrence of them, they don't intrinsically solve the problem of providing "unique" pointer values of a given type other than the NULL pointer of that type. They may make it easier for some implementations to choose techniques for providing this value other than casting integral values other than 0 to the pointer type in question (e.g., declaring some "special" objects of that type, such as "void __sig_ign__(int)"). (I suspect in practice, however, that few, if any, implementations - or, at least, few UNIX implementations - will do so, purely because of inertia.)