all groups > visual c libraries > october 2004 >
You're in the

visual c libraries

group:

'Redefinition; Different type of modifiers'


'Redefinition; Different type of modifiers' sm
10/13/2004 4:09:05 AM
visual c libraries:
Hi All,

I am trying to build a dll from a lib file.

On compilation, I get errors stating 'redefinition; different type of
modifiers', though the dll export statement in the cpp file and the prototype
in the header have no specified modifiers.

The dll export statement looks like this
__declspec(dllexport) DWORD Functionname(Datatype Parameter1);

and the function declaration in the header file is as follows
DWORD WINAPI Functionname(Datatype Parameter1);

Does anybody know how to get over this issue?

Re: 'Redefinition; Different type of modifiers' David Lowndes
10/14/2004 11:13:36 AM
[quoted text, click to view]

You need to have WINAPI in both places (if that's what you really
want), and the declaration should also have __declspec(dllimport).
Have a look at the topic titled "Importing into an Application Using
__declspec(dllimport)" for an example of how to use a single macro in
the 2 circumstances.

Re: 'Redefinition; Different type of modifiers' sm
10/16/2004 1:49:01 AM
Thanks David for your response.

I observed that when WINAPI is used, I won't be able to use
__declspec(dllexport) to export the functions of my dll; since WINAPI uses
__stdcall and dllexport cannot be used with __stdcall.

Is there a workaround to export WINAPI functions?

Thanks once again.


[quoted text, click to view]
Re: 'Redefinition; Different type of modifiers' sm
10/16/2004 3:31:04 AM

Declaring the export function as follows:

DWORD __declspec (dllexport) __stdcall FunctionName(Datatype
Parameter1);

gives the following error on compilation:
d:\testproj\test.cpp(23): error C2375: 'FunctionName' : redefinition;
different linkage

How to get over this error?

Regards.

[quoted text, click to view]
Re: 'Redefinition; Different type of modifiers' David Lowndes
10/16/2004 9:59:19 AM
[quoted text, click to view]

I'm not sure why you think that - you can:

DWORD __declspec (dllexport) __stdcall Functionname(Datatype
Parameter1);


Dave
--
Re: 'Redefinition; Different type of modifiers' sm
10/16/2004 10:19:06 PM
Thanks again for your response.

Do you mean that when the export statement is
DWORD __declspec (dllexport) __stdcall FunctionName(Datatype
Parameter1);

the function declaration in the header file needs to be
DWORD __declspec Functionname(Datatype Parameter1);

But won't such a declaration still give linker errors, since the lib file
would be using __stdcall calling convention in the definition of the function?

So, the question again is, how to export functions which use __stdcall
calling convention?

Regards.

[quoted text, click to view]
Re: 'Redefinition; Different type of modifiers' David Lowndes
10/16/2004 11:37:59 PM
[quoted text, click to view]

This is where we came in isn't it?

The definition in the header file needs to be the same.

Dave
--
Re: 'Redefinition; Different type of modifiers' David Lowndes
10/17/2004 9:36:59 AM
[quoted text, click to view]

No.

When you build your DLL, the header & source file needs to be the
same:

DWORD __declspec (dllexport) __stdcall FunctionName(Datatype
Parameter1);

otherwise you'll get that redefinition error you are seeing.

When you use the header file from the project where you'll call the
function, it needs to be:

DWORD __declspec (dllimport) __stdcall FunctionName(Datatype
Parameter1);

Have a look at that MSDN topic I referred you to originally, that
shows how to use a preprocessor definition to get the correct form of
declspec (dllexport/dllimport) in both circumstances.

Dave
--
Re: 'Redefinition; Different type of modifiers' sm
10/18/2004 10:39:02 PM
I'll try that.

Thanks.

[quoted text, click to view]
AddThis Social Bookmark Button