# confusing compiler warnings

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

## 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 on other sites
What is the exact warning text and what line is it on?

##### Share on other sites
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:

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

##### 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)

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 30
• 9
• 16
• 22