[comp.lang.c] MSC 4.0 "far" question

tad@killer.UUCP (Tad Marko) (09/10/87)

I'm probably being totally silly, but can I do this in small model programs
to save DGROUP space as described in MS Language Newsletter Vol.2 No.8
(BYTE August 1987, page 67).

-----
char far fararray[256];		/* See the pun? */

main()
{
	stuff...

	printf("%s\n", fararray);
}

---------------
What do I need to do to make this work in small model, if possible?  If
not, what exactly do they expect you to be doing in the MS Newsletter?

Thanks,
Tad

--
Tad Marko
..!ihnp4!killer!tad		||	..!ihnp4!alamo!infoswx!ntvax!tad
UNIX Connection BBS AT&T 3B2		North Texas State U. VAX 11/780

"Hi there!" -- Peter Gabriel in "Big Time"

davidsen@steinmetz.steinmetz.UUCP (William E. Davidsen Jr) (09/10/87)

In article <1510@killer.UUCP> tad@killer.UUCP (Tad Marko) writes:
|I'm probably being totally silly, but can I do this in small model programs
|to save DGROUP space as described in MS Language Newsletter Vol.2 No.8
|(BYTE August 1987, page 67).
|
|-----
|char far fararray[256];		/* See the pun? */
|
|main()
|{
|	stuff...
|
|	printf("%s\n", fararray);
|}
|
|---------------
|What do I need to do to make this work in small model, if possible?  If
|not, what exactly do they expect you to be doing in the MS Newsletter?

The printf routine is expecting a near pointer in this model, and the
only *reliable* way to fix that is to move the data to a local array.
far arrays work reasonably well with pointer arithmetic and subscripts,
but far addresses passed into library routines don't work.

I would also advise you to declare the value as a pointer and then get a
value from halloc at runtime. This will improve portability to future
versions.
#  char far *foo, *halloc();
#  (stuff)
#  foo = halloc((long)256);  /* i may be remembering the name halloc 
#                               incorrectly, it's the far hugh allocate
                                in any case */
|
|Thanks,
|Tad

I hope I helped.
-- 
	bill davidsen		(wedu@ge-crd.arpa)
  {uunet | philabs | seismo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me