TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Mario Semo
from: Jonathan de Boyne Pollard
date: 1997-01-27 22:10:40
subject: Dll Init/Term

MS>
  > here's a long full version of dll-initterm for vacpp for
  > OS/2 and Windows from IBM:
MS>

  Interesting.  I disagree with their putting user code in _DLL_InitTerm,
  however.  User code is better off driven by the constructor and
  destructor of a class instance with static storage duration.  That way,
  it is more exception-proof, and the programmer is assured that at the
  time that his initialisation/termination code is run, the C++ RTL is
  fully available.

  In their code that you quoted, placing initialisation code at the point
  of the "user code goes here" comments would restrict the programmer to
  not using any C++ RTL functions during DLL initialisation, since the
  call to _CRT_Init would not have yet occurred at that point.

  I suppose, in a way, mine is a minimalist approach.  DLL initialisation
  and termination is such a compiler-dependent thing that I advocate
  putting as little user code as possible in the actual _DLL_InitTerm/
  _dllmain/__dll_initialize function, and using more "conventional"
  mechanisms (like constructors and destructors) for user initialisation
  and termination.

  Having a class instance that represents the DLL can be a handy thing to
  have around, anyway ... (-:

  > 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 54/99 270/101 620/243 625/160 711/401 413 430 934 712/311 407
SEEN-BY: 712/505 506 517 623 624 704 713/317 800/1
@PATH: 440/4 141/209 270/101 712/624 711/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™.