| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Dll Init/Term |
Jonathan de Boyne Pollard wrote in a message to Mario Semo: JdBP> Interesting. I disagree with their putting user code in JdBP> _DLL_InitTerm, however. User code is better off driven by JdBP> the constructor and destructor of a class instance with JdBP> static storage duration. That way, it is more JdBP> exception-proof, and the programmer is assured that at the JdBP> time that his initialisation/termination code is run, the JdBP> C++ RTL is fully available. JdBP> In their code that you quoted, placing initialisation code JdBP> at the point of the "user code goes here" comments would JdBP> restrict the programmer to not using any C++ RTL functions JdBP> during DLL initialisation, since the call to _CRT_Init JdBP> would not have yet occurred at that point. More to the point, their way of doing this would disable several features of the C++ language, particularly exception handling. This is compiler-dependent but would still fail in all actual implementations I know about. While most programmers probably do not make direct use of the exception facilities of C++, many important libraries do, including STL and whatever ICLUI is called now. Your approach avoids this problem. JdBP> I suppose, in a way, mine is a minimalist approach. DLL JdBP> initialisation and termination is such a compiler-dependent JdBP> thing that I advocate putting as little user code as possible JdBP> in the actual _DLL_InitTerm/ _dllmain/__dll_initialize JdBP> function, and using more "conventional" mechanisms (like JdBP> constructors and destructors) for user initialisation and JdBP> termination. I don't think this is a close call. Your approach is clearly better. -- Mike ---* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107) 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: 323/107 396/1 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™.