• Advertisement
Sign in to follow this  

Static data/functions in a dll

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