In a DLL why should a wstring pointer not work?

  • Thread starter Thread starter ananda vardhana
  • Start date Start date
A

ananda vardhana

Guest
Hello,

MyFunc() does not build and MyFunc1() builds and works.

I get the following error for MyFunc():

error LNK2019: unresolved external symbol _invalid_parameter referenced in function "void * __cdecl std::_Allocate_manually_vector_aligned<struct std::_Default_allocate_traits>(unsigned __int64)" (??$_Allocate_manually_vector_aligned@U_Default_allocate_traits@std@@@std@@YAPEAX_K@Z)
error LNK2019: unresolved external symbol _CrtDbgReport referenced in function "void * __cdecl std::_Allocate_manually_vector_aligned<struct std::_Default_allocate_traits>(unsigned __int64)" (??$_Allocate_manually_vector_aligned@U_Default_allocate_traits@std@@@std@@YAPEAX_K@Z)


This failure happens only in the context of a DLL in a regular function call this works fine. Why is that? I guess in a DLL we have to do something more to tell the function about the space available.

One more related question. How can one connect the these Linker error back to the source code. The error does not publish the line number nor the names of variable that is causing the error. Is there a way to force VS2019 to give out more helpful error message.

Please advice

thanks

ananda

_declspec(dllexport)
BOOLEAN
MyFunc(
wstring* PErrMsg
)
{
*PErrMsg = L"abcd";
return TRUE;
}

_declspec(dllexport)
BOOLEAN
MyFunc1(
char * PErrMsg1
)
{
sprintf_s(PerrMsg1, 10, "xyz");
return TRUE;
}

Continue reading...
 
Back
Top