|
|
Thanks for the answer. I guessed that is what would happen but I
couldn't find any documentation, can you provide a link to the relevant
Borland documentation?
Actually I'm mostly learning C from the book by H. Schildt, which is
excellent but it doesn't mention near and far pointers at all. I find
them quite confusing, so I think any book should explain them clearly.
As for being obsolete, the good thing is that Borland have released
Turbo-C for free now, so there's no need to worry about Micro$oft
license fees. Also C doesn't change much!
In article <fsebsa$uf3$1@xxxxxxxx>, jacob@xxxxxxxxxx says...
>
>
>Simon wrote:
>> Hello friends,
>>
>> I have a couple of doubts about pointers in C.
>>
>>
>> 1) I have a function with prototype is :
>>
>> my_funtion(char far * char);
>>
>> I need to pass it an array of char which I have defined as follows:
>>
>> char my_array[10]
>>
>> The question is: is it allright to typecast to a far pointer? e.g.
>> int i=my_function( (char far *) ( (char *) my_array );
>>
>> I think I am still only passing a near pointer, so how do I force
>> the segment to be passed also?
>>
>
>If I remember correctly, the segment will be added when
>you cast a near pointer to a far one, i.e. the current data
>segment will be passed. You should look at the assembly
>generated to be sure.
>
>>
>> 2) As expected, (char far *) NULL is NULL, but if I set
>> char near *x = NULL,
>> then (char far *)x is non-NULL (the segment is non-zero)!
>
>Probably because the data segment is added to the NULL pointer
>see above...
>
>>
>> This seems crazy, it means that if you have a prototyped function
>> with a far pointer argument (maybe NULL) and you have some
>> near-mode address from somewhere else (maybe NULL),
>> you have to handle the NULL case specially. What's going on?
>>
>>
>> I am using Borland Turbo-C 2.01 if it's relevant.
>>
>
>Forget that stuff. You are programming for a system that is
>around 20 years old. All this stuff is obsolete.
>
>P.S. There was in this group someone that loved TURBOC. I am
>surprised he doesn't answer your question.
>
>--
>jacob navia
>jacob at jacob point remcomp point fr
>logiciels/informatique
>http://www.cs.virginia.edu/~lcc-win32
|
|