Unresolved external symbol int __cdecl test(void const *, int) resolution process

Scenes

        Integrating the DLL module code into the existing calling project, the following errors occurred during the linking process:

: "__Int64 __thiscall Test (struct PARAMS_T , struct RESULT_t &) public" error LNK2019 unresolved external symbol "int __cdecl Add (void const * , int)" symbol in the function
to be references

the reason

        The Add function is declared as follows:

 int  Add(void const* p , int timeout = 0);

The implementation interface is as follows:

 int  Add(void const* p){}

Explain the problem caused by the inconsistency between the function declaration and the implementation interface

Amend as follows: int Add(void const* p, int timeout){}

Key analysis: The compiler defaults to __cdecl, so there will be a qualifier before Add.

 _cdecl is the default calling method of C and C++ programs. Every function that calls it contains code to clear the stack, so the size of the executable file generated will be larger than that of the _stdcall function. The function uses a right-to-left stacking method. VC will prefix the function name with an underscore after compiling the function.
    _stdcall is the default calling method of Pascal programs. It is usually used in Win32 Api. The function uses a right-to-left stacking method, and clears the stack when it exits. After VC compiles the function, it will prefix the function name with an underscore, and add "@" and the number of bytes of the parameter after the function name.
    The function of _fastcall mode uses registers to pass parameters. After VC compiles the function, it will prefix the function name with "@", and add "@" and the number of bytes of the parameter after the function name.

Guess you like

Origin blog.51cto.com/fengyuzaitu/2576625