SSEMember
SSEMember

Reputation: 2173

Visual Studios 9 Inconsistent Dll linkage

Basically the line of code

extern char *strlwr       OF((char *s));

gives the error

warning C4273: 'strlwr' : inconsistent dll linkage

and I don't know why. It's not my code so I'm having issues figuring out how to fix it.

Upvotes: 0

Views: 1731

Answers (2)

You can use _strlwr_s instead of strlwr.

Upvotes: 0

Rafael Baptista
Rafael Baptista

Reputation: 11499

look for:

_declspec( dllexport );
_declspec( dllimport );

attached to declarations for strlwr. It is something to do with that.

Basically when you declare strlwr in the dll itself, e.g. when the header containing strlwr is read by code compiled into the .dll it should be declared export.

When code that calls the dll reads the header, it should be declared dllimport.

I tend make macro blocks like:

#ifndef DLL_IFACE
#ifdef DLL_IFACE_EXPORT
#define DLL_IFACE _declspec( dllexport )
#else  // !DLL_IFACE_EXPORT
#define DLL_IFACE _declspec( dllimport )
#endif // !DLL_IFACE_EXPORT
#endif // !DLL_IFACE

Then for all the symbols in a header which is part of the dll interface I declare those symbols with DLL_IFACE. When the header is read by dll code, I start the .cpp file with "#define DLL_IFACE_EXPORT"

Upvotes: 2

Related Questions