Re: c code reusability



Richard Heathfield wrote:
Michael Wojcik said:
Another is that it
becomes too easy to introduce fresh bugs into a previously working
program.

Since static linking makes it equivalently hard to correct bugs in
an already-buggy program, this is a wash.


Not so. Just fix the bug and ship the executable, which is no harder than fixing the bug and shipping the DLL.



If your dll is used by several client executables, you can't ship the executable, they would have to relink with a new version of the
static library you ship to them. This is not always possible since
it supposes a toolset (linker, libraries, etc) that may not be at available at the client's site. Just shipping a dll makes only a file
copy necessary.


Another points for dlls that has not been mentioned is that (at least
under windows) dlls are called when loaded to initialize themselves.

This is very practical for libraries that need heavy initialization
stuff. Using a static library you are forced to write:

if (!initialized)
DoInit();

at the start of each entry point...

Dynamic linking can be abused (as anything). It is also the source
of hard to find errors. But just to dismiss it is nonsense.
.



Relevant Pages

  • Re: Memory increasing even when in debug-break
    ... another test machine that is running the app under .Net 1.1 is still ... I'm left wondering whether this bug is even related. ... leak occurs in a process that uses Corperfmonext.dll in the .NET Framework ... to do this whole DLL injection thing for apps that query performance data... ...
    (microsoft.public.vsnet.debugging)
  • Problem with locales in unloaded DLLs
    ... We are making a plugin (DLL) for some application. ... locale crash") didn't come up with something. ... this bug. ... I'm Schobi at suespammers dot org ...
    (microsoft.public.dotnet.languages.vc)
  • Problem with locales in unloaded DLLs
    ... We are making a plugin (DLL) for some application. ... locale crash") didn't come up with something. ... this bug. ... I'm Schobi at suespammers dot org ...
    (microsoft.public.vc.stl)
  • Re: c code reusability
    ... Program X uses DLL Y. DLL Y is "improved", and a bug is introduced. ... At least one OS I use has deprecated static linking for all ... It's way easier to fix a library bug with a patch ...
    (comp.lang.c)
  • Re: code within libraries vs code within same project
    ... Is this a bug in System.Diagnostics.StackTrace? ... //the .dll do not appear to have all the info, particularly filename. ...
    (microsoft.public.dotnet.languages.csharp)

Loading