TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: John Lisek
from: Jonathan de Boyne Pollard
date: 1996-05-11 17:53:28
subject: Watcom C and 16-bit dll

JL>
  > I want to port some old MSC OS/2 1.3 dll's to 16-bit watcom
  > C. I have stumbled on a limitation in the watcom 10.0
  > compiler. I am not able to to find any switch which will
  > generate the right prologue/epilogue in exportet functions
  > (load of the right DS). The -zw switch only works for
  > windows programs. Does anyone know it this has been
  > corrected in the newer version of Watcom C.
JL>

  It doesn't need to be corrected, since it isn't a bug.

  The -zw, -zW, and -zWs switches control the generation of the prologues
  necessary on DOS+Windows for "instance thunking" (i.e. all of the messy
  mechanics of MakeProcInstance).  In 16-bit OS/2 there is no such thing.

  In 16-bit OS/2 all that is required of a function that can be called
  from outside the EXE or DLL containing it is that it ensure that it
  loads the DGROUP for the EXE/DLL into the DS register on entry.  There
  are no instance thunks, no MakeProcInstance, and the much longer
  function prologues used by DOS+Windows are not required.

  To do this, all that is necessary is to add the __loadds keyword to the
  function declaration and definition.

  ( With Borland C++ it is even easier.  Declaring a function as "huge"
    instead of "far" has the same effect as adding the
"loadds" keyword.
    16-bit Watcom C++ does not support this.  )

  I don't have the 16-bit Toolkit readily to hand here (I haven't done any
  16-bit OS/2 work for years) but I believe that the EXPENTRY macro
  declared in  includes __loadds.

  If it does, then I strongly advise using EXPENTRY rather than using
  __loadds on your function definitions, since porting your application to
  32-bits will be made that much easier.  EXPENTRY is declared in the
  32-bit Toolkit, and code using it can be ported without change.  Whereas
  __loadds is specific to the 16-bit world, and has no 32-bit equivalent.

  You are strongly considering making your DLLs 32-bit, aren't you ?

  > JdeBP <
___
 X MegaMail 2.10 #0:

--- Maximus/2 3.01
* Origin: DoNoR/2,Woking UK (44-1483-725167) (2:440/4)
SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1
@PATH: 440/4 141/209 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.