When I am trying to return a QString from a method I am getting linker error.
My code is like:

extern "C"{
_declspec QString _stdcall function1(char* name);


I am using MSVC 6.0 compiler.
Could any body help me?

(NOte: If I remove _stdcall its working fine)

Thanks in Advance,

Recommended Answers

All 6 Replies

>>(NOte: If I remove _stdcall its working fine)
Then what's the problem? Leave _stdcall out then.


I am wondering what is the problem with _stdcall,since its working for all other types(pre defined and user defined) except QString

_stdcall and _cdecl are identical and are the default for C and C++ functions. Therefore is never a reason to use _stdcall or _cdecl in C and C++ programs. Using Microsoft compilers that is. What compiler are you using?

I don't know why its not working for you. Are you sure you have the correct prototype? Do you have the source code for the function so that you can verify -- but you probably already did that.

Thanks for reply.
I am using MSVC 6.0.
Me to not sure about the problem


_cdecl and _stdcall has some difference, I think you are calling the function from the library written using different calling convention than the one you are using. Its basically a name decoration issue, not resolved by linkers.

In VC++ 6.0 _cdecl is the default calling convention.

_cdecl In this type convention the caller is responsible for cleaning up the stack.
_stdcall In this type of convention the callee is responsible for cleaning up the stack.

search calling conventions.

commented: Thanks for the correction. +25

_cdecl and _stdcall has some difference,.

Yes you are right. .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.