在看有关MFC的书籍的时候!我遇到了一些小问题:1:MFC类库中的一些类中,在声明成员变量和成员函数时,有"PASCAL"修饰,请问他是宏名吗?那有什么作用呢??!例如CObject类中!
2:还有经常看到一些字串头几个字母是“AFX”,请问他是哪一个或几个单词中字母的缩写!?例如消息映射中就经常看到!!!!!!
2:还有经常看到一些字串头几个字母是“AFX”,请问他是哪一个或几个单词中字母的缩写!?例如消息映射中就经常看到!!!!!!
Many global functions start with the prefix "Afx" — but some, such as the dialog data exchange (DDX) functions and many of the database functions, deviate from this convention. All global variables start with "afx" as a prefix. Macros do not start with any particular prefix, but they are written all in uppercase.全局的函数和变量以AFX为前缀。
__pascal是一种调用约定。还有__cdecl,__stdcall约定。但是,下面是msdn中的东西。
The __pascal, __fortran, and __syscall calling conventions are no longer supported. You can emulate their functionality by using one of the supported calling conventions and appropriate linker options. WINDOWS.H now supports the WINAPI macro, which translates to the appropriate calling convention for the target. Use WINAPI where you previously used PASCAL or __far __pascal.
Home | Overview | How Do IMicrosoft 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
Note For related information, see Decorated Names. 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 *);
第二个问题好像知道,但说不清,也接着学习吧!帮你UP!
A: Application
f: framework
x: 你知道,很多人,包括微软,喜欢这个字母,XML,ActiveX,Windows XP,好像没特别含义
Home | Overview | How Do IMicrosoft Specific —>The __stdcall calling convention is used to call Win32 API functions. The callee cleans the stack, so the compiler makes vararg functions __cdecl. Functions that use this calling convention require a function prototype. The following list shows the implementation of this calling convention.Element Implementation
Argument-passing order Right to left.
Argument-passing convention By value, unless a pointer or reference type is passed.
Stack-maintenance responsibility Called function pops its own arguments from the stack.
Name-decoration convention An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as int func( int a, double b ) is decorated as follows: _func@12
Case-translation convention None
The /Gz compiler option specifies __stdcall for all functions not explicitly declared with a different calling convention. Functions declared using the __stdcall modifier return values the same way as functions declared using __cdecl. END Microsoft SpecificExample
In the following example, use of __stdcall results in all WINAPI function types being handled as a standard call:// Example of the __stdcall keyword
#define WINAPI __stdcall