www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/28/11:16:03

From: George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: far keyword
Date: 28 Jan 1998 14:58:44 GMT
Organization: Oxford University, England
Lines: 39
Message-ID: <6anh34$sfi$1@news.ox.ac.uk>
References: <34CF3BCE DOT 9E13A53F AT tp DOT silkera DOT net>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Wed, 28 Jan 1998 22:08:15 +0800 in comp.os.msdos.djgpp Liche
<liche AT tp DOT silkera DOT net> wrote:

: Does djgpp not support the far keyword?  For example: char far* test =
: (char far*) 0x00000000L.

No.  It doesn't need it in the same way that real-mode DOS compilers
do; you never need to allocate anything on the `far' heap since
there's so much memory available on the `near' heap.  Under djgpp
there is no `far' heap at all.

The other use of far pointers in real-mode DOS is to access physical
memory locations directly, for hardware programming etc.  This is
dirty, and while you can do it in djgpp it's a little more
complicated.  You should have a look at section 18 of the FAQ for
information on how to do this.

In general, though, you can remove the word `far' throughout your
sources.  If portability back to older compilers is a requirement, you
can just do something like this:

#ifdef __DJGPP__
#define far
#endif

to make the preprocessor remove them for you on djgpp compilations;
however you should also look at each use of `far' to check that
removing it is really going to work (i.e. what you're doing falls
under the first paragraph above).  If backward portability is not an
issue, it's probably best to remove the `far' pseudokeyword by hand,
so that you do see them all and can decide whether or not it's
appropriate to just remove the word.

BTW, you shouldn't rely on (void *)0x00000000L being the value of a
null pointer -- #include <stdlib.h> and use NULL instead.  Platforms
can have different values of a null pointer.

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019