Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 (Tek) 9/28/84 based on 9/17/84; site tekig4.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!harvard!think!mit-eddie!genrad!decvax!tektronix!tekig5!tekig4!rosalia From: rosalia@tekig4.UUCP (Mark Galassi) Newsgroups: net.lang.c Subject: Re: Need some examples Message-ID: <185@tekig4.UUCP> Date: Tue, 6-Aug-85 11:35:14 EDT Article-I.D.: tekig4.185 Posted: Tue Aug 6 11:35:14 1985 Date-Received: Sun, 11-Aug-85 06:18:42 EDT References: <299@brl-tgr.ARPA> Reply-To: rosalia@tekig4.UUCP (Mark Galassi) Organization: Tektronix, Beaverton OR Lines: 40 In article <299@brl-tgr.ARPA> you write: > > There are a variety of funny little problems with using the 0 >pointer in C. Recently I have gotten into a debate with a friend >about passing a 0 pointer to a function. We agree that given >a function declaration like > >f(ptr) >foo *ptr; >{ > [code] >} > >calling f(0) is dangerous. But my friend contends that calling >f() with a zero char pointer, e.g. f((char *)0), is safe, because >(char *) is the largest pointer, and that he doesn't know of a C >implementation that doesn't pass all pointers as the largest >possible pointer (ala the way floats always get passed as doubles). There is a problem: when you work with the Intel 80286 in large models instead of small ones **(for those who have never worked with this misfit of nature, the 80286 cannot use more than 64K of memory unless you do some bank switching, which is such a pain in the neck that one usually tries to use the small model of program in which you only make use of 64K)**, you have to be careful because pointers are 32 bits in large model, and 16 bits in small model. This is a horrible situation because you cannot even trust to do "#define NULL 0L", because that will not work in small model and you will have garbage on the stack. On the other hand "#define NULL 0" will not work for the large model. The only solution is to cast things properly with (char *), but then you have to compile all your libraries twice, once with the large model C compiler and once with the small one. So much for that, and the chains of the past (4004) weigh heavilly upon us programmers, while the salesmen are always happy to talk about how the segments "enable portability of software". Mark Galassi ...!tektronix!tekig4!rosalia ...!tektronix!reed!rosalia