iam@waikato.ac.nz (Ian McDonald) (11/28/90)
I am having fun at the moment with memory models. At the moment I am using code like : read(hFile,lpMsgBuffer,size); and compiling in large model. I would prefer to have it compiled under small or medium model as that gives moveable data segments. If I do though it can't seem to reference lpMsgBuffer which is a far pointer to a buffer - because it is global heap. If I use small model (ie near data pointers) then lpMsgBuffer is converted to near incorrectly. BTW I am using Microsoft C 6. Is there an easy solution? I will post a summary of any replies received as I am sure other people will have this problem!! (Maybe it should be included in FAQ??) -- ------------------------------------------------------------------------- Ian McDonald | 52 Cook Street| Hamilton | This space free for advertising !! New Zealand | +64-71-563438 | I am not ignoring you - I can't return mail!!
iam@waikato.ac.nz (Ian McDonald) (11/28/90)
> I am having fun at the moment with memory models. > > At the moment I am using code like : > read(hFile,lpMsgBuffer,size); > > and compiling in large model. I would prefer to have it compiled under small > or medium model as that gives moveable data segments. If I do though it can't > seem to reference lpMsgBuffer which is a far pointer to a buffer - because it > is global heap. If I use small model (ie near data pointers) then lpMsgBuffer > is converted to near incorrectly. BTW I am using Microsoft C 6. > > Is there an easy solution? > Sorry about this folks. I have just found out the answer (and how inexperienced I am with PC C). The answer seems to be to use _lread and lstrlen etc. It is a bit of a "dirty" approach and one that I don't like but then this isn't UNIX!! ---------------------------------------------------------------------------- Ian McDonald | 52 Cook Street| Hamilton | This space free for advertising !! New Zealand | +64-71-563438 | I can receive mail but can't reply to it.
goodearl@world.std.com (Robert Goodearl) (11/28/90)
In article <2365.27537b67@waikato.ac.nz> iam@waikato.ac.nz (Ian McDonald) writes: >I am having fun at the moment with memory models. > >At the moment I am using code like : > read(hFile,lpMsgBuffer,size); > >and compiling in large model. I would prefer to have it compiled under small >or medium model as that gives moveable data segments. If I do though it can't >seem to reference lpMsgBuffer which is a far pointer to a buffer The solution for this particular problem is to use the windows function _lread which takes an LPSTR for the buffer parameter. Read chapter 14 of the Guide to Programming. pp 14-8 lists a number of functions that take LPSTR parameter. Section 14.5.4 talks about file io using _lopen, _lcreate, _lread and _lwrite. You should be aware that you don't use the standard C libraries (or .h files) when compiling for windows 3.0 with C 6.0. All the .h files and .lib files needed are provided with the SDK. Also, be sure to define _WINDOWS at the top of your source file or on the command line for the compiler when compiling for a windows executable. When compiling for a DLL, define BOTH _WINDOWS and _WINDLL. -- Bob Goodearl -- goodearl@world.std.com