Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rna!dan From: dan@rna.UUCP (Dan Ts'o) Newsgroups: comp.sys.ibm.pc Subject: MSC 4.0 problem Message-ID: <640@rna.UUCP> Date: Thu, 20-Aug-87 17:06:43 EDT Article-I.D.: rna.640 Posted: Thu Aug 20 17:06:43 1987 Date-Received: Sat, 22-Aug-87 11:46:03 EDT Organization: Rockefeller Neurobiology Lines: 51 While converting a large C program from small model to large model using MSC 4.0, I encountered a problem not found on all other (UNIX) C compilers. It went something like this: char *s0, *s1, *buf0, *buf1; buf0 = malloc(512); /* Get two char buffers */ buf1 = malloc(512); gets(buf0); /* Fill with a line of text */ strcpy(buf1, buf0); /* Copy to second buffer */ /* Some kind of lexical analysis, moving s0 to somewhere within buf0 */ for (s0 = buf0; *s0 && *s0 != '/'; s0++); if (*s0 == '/') /*WARNING*/ s1 = buf1 + (s0 - buf0);/* I want s3 to point in the same respective position in buf1 */ The last line provoked 2 warnings from MSC 4.0, both something like: Warning: conversion of far pointer to int. The binary result did not run. Fare enough, so I explicitly casted an (int): s1 = buf1 + (int)(s0 - buf0); With this code, I got one such warning and the code still didn't run. I didn't try casting to (long), figuring that you can't have objects greater than 64Kb anyways, although (long) might have made sense. Instead I settled for this, which removed the warning and worked: int n; ... n = s0 - buf0; s1 = &buf1[n]; I believe, int n; ... n = s0 - buf0; s1 = buf1 + n; also works. Can anyone tell me the big difference between casting (int) which didn't work and assigning explicitly to an int, which did work ? Thanks. Cheers, Dan Ts'o Dept. Neurobiology 212-570-7671 Rockefeller Univ. ...cmcl2!rna!dan 1230 York Ave. rna!dan@nyu.arpa NY, NY 10021