Jump to content
  • Advertisement
Sign in to follow this  
Brice Lambson

DLL Look-Outs

This topic is 4833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
...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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!