DLL Look-Outs

Started by
16 comments, last by Brice Lambson 19 years ago
It's me again -- the kid that plunges in the deep end without knowing how to swim well enough. So, I split my Engine (2D via SDL) into Dynamicly Linked Libraries: Kernel.dll (imports SDL, SDL_image) Network.dll (imports Kernel, SDL_net) Audio.dll (imports SDL, SDL_mixer, Kernel) GUI.dll (imports SDL, SDL_image, Kernel) Script.dll (imports SDL, SDL_image, SDL_mixer, SDL_net, Kernel, Network, Audio, GUI) Engine.exe (imports SDL, SDL_image, SDL_mixer, SDL_net, Kernel, Network, Audio, GUI, Script) ...but now only half the data files load, and the graphics, that are drawn per-pixle by the code, are discolored. What might be the problem here? Or in other words: What are some things that I should look out for when using DLLs? Thanks. -Brice
--Brice Lambson
Advertisement
The biggest problem to look out for, in my experience, is using DLLs needlessly. Dynamic libraries serve a purpose, and that purpose is mostly to prevent identical code from being loaded into memory multiple times for different applications. Certain commonly used systems benefit from being made DLLs. But if only a single application is ever going to access a system, I question the need for it being made as a dynamic library in the first place.
If I had to guess, I would guess that there are some objects that are meant to be singletons but multiple instances are being made.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
I'm using DLLs so that if someone modifies part of the engine, you can just change the DLL file instead of having a million exe files for all the different possibilitys, and also it's easier to release new versions with updated parts by only releasing a new DLL for that part (instead of a-whole-nother EXE file).

All my singletons have checks on them -- an exception is thrown if that should ever happen. (...and yes, I do catch these exceptions.)
--Brice Lambson
Wait, so did all of this work before you moved it to .dlls?
Yes, it worked just fine, but now the font files (custom file format containing bitmap font data), and also the buttons which were drawn by the code are tinted red.
--Brice Lambson
I fixed it! Either I accidentally flipped the SDL_BYTEORDER == SDL_BIG_ENDIAN code, or DLLs switch from Big Endian to Little Endian. I'm going to guess that I screwed it up. :D Thanks for all you thoughts tough, I did learn a few things to look out for.
--Brice Lambson
Quote:Original post by Brice Lambson
I'm using DLLs so that if someone modifies part of the engine, you can just change the DLL file instead of having a million exe files for all the different possibilitys, and also it's easier to release new versions with updated parts by only releasing a new DLL for that part (instead of a-whole-nother EXE file).

All my singletons have checks on them -- an exception is thrown if that should ever happen. (...and yes, I do catch these exceptions.)


This isn't probably something you should use exceptions for. This is more of a logic error and they are better handled by asserts see Sutter and Alexandruescu item 68.

CHeers
Chris
CheersChris
...you're saying I should abort the entire program just because somebody accidentally created say two error logs?! It seems more logical to me just to throw an exception, catch it, and recover.
--Brice Lambson
Well actually Herb Sutter is saying it, you can take it up with him, exceptions should not not be used to catch logic errors. I just happen to agree with him.

In your case you should assert, don't hack around bad practices. Enforce good ones!!

Cheers
Chris
CheersChris

This topic is closed to new replies.

Advertisement