0228 cdecl C2664 msdn

将一段C代码转换为CPP代码,结果出现:
Rtp.cpp(111) : error C2664: \’er\’ : cannot convert parameter 2 from \’void (const ON__ *,void *)\’ to \’void (__cdecl *)(const ON__ *,void *)\’
        None of the functions with this name in scope match the target type

看看资料:
Compiler Error C2664
\’function\’ : cannot convert parameter number from \’type1\’ to \’type2\’

The specified parameter of the specified function could not be converted to the required type. If you’ve encountered this error on code which compiled with an earlier version of Visual C++, please read Technote: Improved Conformance to ANSI C++ for more information.
The following is an example of this error:
class A &leftsign;&rightsign; a;
func( int, A );
void main()
&leftsign;
   func( 1, 1 );  // error, no conversion from int to A
&rightsign;
Tips
Recheck the prototype for the given function and correct the argument noted in the error message. If necessary, an explicit conversion may need to be supplied.

好像就是说类型转换错误,没有什么用

__cdecl
Microsoft Specific —>

This is the default calling convention for C and C++ programs. Because the stack is cleaned up by the caller, it can do vararg functions. The __cdecl calling convention creates larger executables than __stdcall, because it requires each function call to include stack cleanup code. The following list shows the implementation of this calling convention.

Element Implementation
Argument-passing order Right to left
Stack-maintenance responsibility Calling function pops the arguments from the stack
Name-decoration convention Underscore character (_) is prefixed to names
Case-translation convention No case translation performed
Place the __cdecl modifier before a variable or a function name. Because the C naming and calling conventions are the default, the only time you need to use __cdecl is when you have specified the /Gz (stdcall) or /Gr (fastcall) compiler option. The /Gd compiler option forces the __cdecl calling convention.

Example
In the following example, the compiler is instructed to use C naming and calling conventions for the system function:

// Example of the __cdecl keyword
_CRTIMP int __cdecl system(const char *);

END Microsoft Specific

看看好像也没有什么用

历史博文

标签:, ,
六月 20, 2006 at 10:57 上午 by yippee 1,038 次
Category: Dev
Tags: , ,