error C2733 second C linkage of overloaded function 'function' not allowed

33,153

I have no experience with MFC, anyway i'll try to answer. Such error message appears when an extern "C" function is declared with a different set of parameters. For example:

extern "C" int myfunc(int);
extern "C" int myfunc(char);

In your case, the two declarations are probably related to char*:

extern "C" char* StrCatW(char*, char*);
extern "C" wchar_t* StrCatW(wchar_t*, wchar_t*);

Try turning off Unicode support in your solution: i guess, if the dll is really old, it somehow declares StrCatW with char* arguments, conflicting with some other declaration.

If that doesn't help, turn on preprocessed output (/E compiler switch, as far as i recall) - it will output a very large file, so look for StrCatW in it, maybe it will give you some clue on what is going on.

Share:
33,153
swcraft
Author by

swcraft

Updated on June 24, 2020

Comments

  • swcraft
    swcraft almost 4 years

    I am trying to compile old cpp MFC project in Visual Studio 2010 pro.

    It uses dll which is compiled using Labview, and I am adding this information because I don't know what is causing the error message..

    The error messages show up on multiple functions, all same error type.

    error C2733: second C linkage of overloaded function 'function name' not allowed.
    

    the 'function name' includes: 'StrCatW', 'StrCmpNW', 'StrCmpW', 'StrCpyNW', and 'StrCpyW'

    I found a similar case on the web.

    Although the suggestion in the link didn't solve in my case and I still see the same error messages.

    Thanks in advance for anyone trying to help.

  • swcraft
    swcraft over 12 years
    thanks for the suggestions.. Turned off Unicode support and didn't work so I am going to try the preprocessed output and see what's going on
  • swcraft
    swcraft over 12 years
    Hi As I turn on the preprocess (/P in VS 2010), I see LINK error asking for stdafx.obj, which is the obj file of first cpp in my source files list. I found MSDN error explanation which seems related to what you suggested.. msdn.microsoft.com/en-us/library/5z9es6ec(v=vs.71).aspx
  • swcraft
    swcraft over 12 years
    I solved the problem simply by commenting out from header file the functions in the list of error 'second C linkage'
  • Nav
    Nav over 11 years
    In my case, the error was because I declared a function in my DLL as extern "C" {DECLDIR void GetSetFrameFunctionPointers( void (*myfunc)(int i) );} in the header file and implemented it as extern "C" {DECLDIR void GetSetFrameFunctionPointers( void (*myfunc)() );} in the cpp file. The int i was missing, and that had caused the error.
  • swcraft
    swcraft over 11 years
    yeah, I guess that will also be in category of what David Rodríguez - dribeas commented on the first thread. In your case, I assume C/C++ takes in no-argument function as valid however that will still create error because name mangling is disabled in C linkage.
  • andreaciri
    andreaciri about 7 years
    In my case the 'extern "C" __declspec(dllexport)' function declared in my dll conflicted with a Windows function with the same name. Changing to a less common name solved the problem.