Jump to content
  • Advertisement
Sign in to follow this  
shalrath

confusing compiler warnings

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

Just a couple of questions, I'm using VC++7(2002) to compile a DLL, and this declaration produces a 'macro redefinition' warning:
#ifdef DMDLLEXP
	#define DMD3D_EXP __declspec(dllexport)
#else
	#define DMD3D_EXP __declspec(dllimport)
#endif

This is all that's in the file... I'm a little baffled, any ideas? Also, when using this definition like so
class DMD3D_EXP CDark
{
functions...
}

In the code, all of the functions in the class give the warning: 'inconsistent dll linkage' Not from the header with the class definition, but the cpp file with all the function definitions in it. I'm confused, any ideas?

Share this post


Link to post
Share on other sites
Advertisement
The line is the:

#define DMD3D_EXP __declspec(dllimport)

The exact warning is:

warning C4005: 'DMD3D_EXP' : macro redefinition


For the other one, all functions produce this warning:

warning C4273: inconsistent dll linkage


I've not been able to find anything on MSDN, hence the post here.

Share this post


Link to post
Share on other sites
That macro redefine error probably means you forgot to add include guards (or similar) around that #if-#else-#endif block. Try this:

#ifndef DMD3D_EXP
#ifdef DMDLLEXP
#define DMD3D_EXP __declspec(dllexport)
#else
#define DMD3D_EXP __declspec(dllimport)
#endif
#endif

The other error I don't know, maybe DMDLLEXP is (un)defined between two inclusions of this header, which would cause a problem with DMD3D_EXP being redefined as the other meaning. In that case, you most likely forgot to put include guards around the headers using this as well.
(or if this happens while linking, you may have #defined DMD3D_EXP in one translation unit but not the other and are trying to link them together. Those look like MSVC errors, which I'm not really familiar with)

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!