Predefined macro __FUNCDNAME__ in C++/CLI project

RLWA32 49,536 Reputation points
2023-07-23T22:52:38.77+00:00

A C++/CLI class library project targeting .Net 6 exports a function that has C++ name decoration. In order to simplify using this function from a C module I also want to export an alias. To avoid needing a DEF file and automatically obtain the decorated name the function is defined as follows:

__declspec(dllexport) CppWrapLibrary::CppWrap* CreateWrapper()
{
#pragma comment(linker, "/EXPORT:" __FUNCTION__ "=" __FUNCDNAME__ "")
    return static_cast<CppWrapLibrary::CppWrap*>(new CppWrapLibrary::CppWrapImpl);
}

However, although an alias is created in the resultant .obj file the decorated name seems to be incorrect and does not agree with decorated name generated through __declspec(dllexport).

Following is a dump of the directives in the module that illustrates the discrepancy. Is the predefined macro FUNCDNAME broken?

funcdname

Developer technologies C++
Developer technologies Visual Studio Other
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.