Sign in to follow this  

Static data/functions in a dll

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

This topic is 4359 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this