Jump to content
  • Advertisement
Sign in to follow this  

Static data/functions in a dll

This topic is 4666 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

I was writing a dll that has something like this in it...

static SystemRecord SystemLocalHost;

SystemRecord * GetSystemRecord( )
	return &SystemLocalHost;

This is inside a C file and GetSystemRecord is defined in it's header. Normally I dont' use globals but it's impossible to avoid in this instance, so I encapsulated it around a function and kept it local to the C file. I thought that was good practice. However, this function will always return NULL, and as you can see for yourself, it clearly should not. This code is inside a Windows dll compiled with MinGW 3.4 and executed from a program linked to it using the same compiler. It may be helpful to note that the same error presists whether SystemLocalHost is static or not, and regardless whether I make GetSystemRecord __stdcall or not. Also, the program does not call this function directly, but it's called by proxy (through an other function) and I determined the error by using MessageBox on the the return value of this.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!